The current 1.x xmlsitemap directory structure does not follow Drupal rules and prevent the localisation system from successfully importing all translation files. As you may seen I've updated the splitted POT files with POTX yesterday with php potx-cli.php --mode=multiple.
The default file structure is to keep the "default.de.po" in the root translation folder "xmlsitemap/translation" (compare it yourself with CCK and others). Therefore the "default.de.po" is not automatically imported by the core translation system - if there is no module/info in the parent folder. I have no idea why the main module required by all submodules have been moved into a subdirectory and it seems to cause issues. This is not the way how we build modules in Drupal.
Therefore the "xmlsitemap/xmlsitemap" folder files need to be moved back to the "xmlsitemap" root folder to get this PO import bug fixed.
I saw Dave has already fixed this in 2.x - so this is an 6.x-1.x bug only.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | Translate interface | localhost_1245078518471.png | 95.54 KB | dave reid |
Comments
Comment #1
hass commentedOnly to note, I moved the files to the module root folder and all works well.
Comment #2
Anonymous (not verified) commentedThis will need fixed after #483844: Restore code to beta0. I like the directory structure Kiam came up with but if it causes issues with the translations then I can move the xmlsitemap module back to the parent directory.
Comment #3
avpadernoThe directory structure I came out with is thought to make easier the creation of the translation template file using Translation template extractor. Using that module, it would be enough to select the directory containing xmlsitemap.module, to create the translation template of that module; differently, who creates the template could just select single files that don't contain all the strings to translate.
Comment #4
avpadernoI am lowering the priority, as the directory used by the module doesn't influence Drupal, nor doesn't prevent it from correctly working; plus, this is more a task than a bug report.
Comment #5
hass commentedYou might have made a wrong selection in the POTX web UI. I'm not using the UI as it doesn't have all features like "mode=multiple" that is required for complex projects with many submodules. It's wrong to select a submodule on by one as this would cause duplicate strings in POT files that are shared across the main and submodules. These strings go into default.pot and we do not need to translate the same strings 5 times.
Comment #6
Anonymous (not verified) commentedI will move the xmlsitemap/ directory files back to the main module directory to provide Kiam the ability to do as he says. I agree that it is a bit much to translate the same base strings over and over again. While what you have isn't bad but the current tool set doesn't support it easily and the users aren't that used to not finding an info and a module file in the base directory. Resetting to critical and a bug report to indicate the importance of this issue.
NOTE: Kiam, I don't think it was wrong that you put the module files in a subdirectory and I have seen it elsewhere and have supported that idea. It is just a pain for the translation and easier for this project to change than it is to change all the other projects.
Comment #7
dave reidI don't know why anyone has had problems creating the translation template with the base module in the modules's root directory. If you select this option in the translation template extractor (http://drupal.org/project/potx), it works just fine. That's why I didn't see the need to use the same module structure as 6.x-1.x in 6.x-2.x.
Comment #8
hass commented@Dave: Your selection creates only ONE .POT file with all strings. This is incorrect behaviour... Use the command line version, please.
It's a bug or missing feature in the POTX module, but the source is that we need to add a PECL zip/tar requirements to the potx module to provide the multiple POT files feature in the UI... (the download popup cannot provide more than one file for download) otherwise there are not so many modules having submodules and this is why the prio wasn't yet seen very high on this task. I'm should be an open task in POTX issue queue...
For submodules we should create splitted POT files for the people who do not enable all submodules. It submodules like xmlsitemap_user are disabled the strings are not imported by the language system. Otherwise - if you only have one file (Your selection) the language system - imports strings it never needs and therefore you have a performance degradation on t() function lookups. It makes a difference if you have only 6000 or 10.000 strings imported.
Comment #9
hass commentedCannot find the case... could be 1:1 discussion with Gabor... long time ago. I will open a case soon.
Comment #10
avpaderno@#7: The module allows you to create the translation file from all files whose name starts with xmlsitemap, but if you have a directory includes, the module would not allow you to select it together with xmlsitemap* files.
I don't see a reason to have different .pot files when then the translation file is just it.po, de.po. What is the purpose to have more than one .pot file that must be then used to create a single file per translation? It would be more work because I cannot have xmlsitemap.admin.de.po, xmlsitemap.pages.de.po, but I must have a de.po.
Comment #11
dave reid@hass I totally understand that it only creates one .pot file, just for the base xmlsitemap.module. I repeat the process for all the sub-modules. It works just fine.
Comment #12
avpadernoAnyway, could the directory structure be considered a bug?
I could be old school, but a bug is something that causes the code to not work properly, or to return a wrong result. The code works correctly whichever directory is used for the module (which still needs to be placed in sites/all/modules).
Comment #13
hass commented@Kiam: The language system in core doesn't work this way. If the structure is wrong- the default.de.po is not imported. Therefore it's a bug that the base module (xmlsitemap) does not implement what core supports. Please re-read what I wrote in #8. There is the explanation why splitted files are important.
@Dave: Are you really sure? As I know POTX exports all selected modules including all submodules strings into one file. Keep in mind this are not checkboxes, it's a radio. So with your selection you will not have a default.pot (shared strings) + xmlsitemap.pot (module only strings) + xmlsitemap_*.pot - you only get a xmlsitmap.po with all strings. There is now way to get the default.pot with the UI.
POTX need to have code that generates the splitted POT files on server side in a temp folder, pack them together into an archive and than send all files to the client with the correct directory structure in one download popup. If I remember correctly - this is already in l10n_server implemented and needs porting to POTX...
Comment #14
avpadernoDoes that mean XML sitemap does not work? I think it does work, whatever directory you put the code in. If you are not able to import a translation, that does not mean the code is not working (XML sitemap does not have code to handle translations).
The question was not for you, as you are used to report a not correct English word used in the user interface as a bug. What you think to be a bug is already known; the problem is that your point of view is not the same of the others.
Comment #15
hass commentedYou do not understand how core translation system works and how a modules that depends on core need to work. Learn first than comment.
Comment #16
avpadernoEverybody has something to learn. Somebody needs to learn more difficult things; somebody needs to learn what bug means in programming, and what is the difference between a bug, and a usability case.
Comment #17
hass commentedThe core translation system has an auto import logic implemented. This import process is currently not working properly and the main reason is the file structure of xmlsitemap. Therefore it's pretty save that this is a bug in the file structure of xmlsitemap as it does not follow what core was designed for. I don't like to discuss if core design could be different or not, but I know there are very good reasons how it is build. I do not see where a broken automatic translation file import could ever become a "usability" issue.
Comment #18
Anonymous (not verified) commented@dave, @hass, I see both of you are agreeing with each other without realizing it.
Current 6.x-1.x design:
6.x-2.x design:
Hass has said that the current 6.x-1.x design causes issues with translation because he can't create one .pot file since there is no module in the main directory. He has stated this as a bug because it isn't The Drupal Way(tm). Instead he proposes the directory structure should be the following.
Proposed 6.x-1.x design:
Comment #19
Anonymous (not verified) commentedI hate to pollute this issue but for Kiam's et alia benefit and to get this off my chest; a bug can be relative to design as well as code. The code itself may be coded to design but that doesn't make the design free of flaws. Analyst's who point to the developer of his design without consideration of a flaw in the design as the one at fault usually do not do well AFAIC. Developers who realize the design flaw and keep silent about it also do not do well AFAIC. Design and code are inseparable and both can be faulty. In this case it is merely the fact that the directory structure does not permit ease of translation due to Drupal as a whole so therefore the module is buggy due to other limitations.
Comment #20
avpadernoUsing potx.module, I was able to create the template translation file for xmlsitemap.module with the actual directory structure; if the problem would be the directory structure, then I would not have been able to create it. Plus, if the problem would be the directory where xmlsitemap.module is, we should put all the XML sitemap modules into one directory; I don't see any reasons of having the problem with xmlsitemap.module, but not xmlsitemap_taxonomy.module, which is in its own directory.
Are there any differences between xmlsitemap/xmlsitemap/xmlsitemap.module, and xmlsitemap/xmlsitemap_taxonomy/xmlsitemap_taxonomy.module?
About what is defined as bug, Common types of computer bugs doesn't report any design problems, nor the wrong use of an English word in the user interface as bugs.
Anyway, somebody should explain why the core translation system is able to work with xmlsitemap/xmlsitemap_taxonomy/xmlsitemap_taxonomy.module, but not with xmlsitemap/xmlsitemap/xmlsitemap.module.
Comment #21
hass commentedThe logic is - that the modules root folder is the base folder where POTX runs in. It creates folders and files if l10n_server extracts translation files. Project module will in future commit the latest translation files to CVS or will at least package translation with the releases with all known strings of a translation. This export have the logic to create a directory structure that is based on default core behaviour. For e.g. it creates the folder "modules/xmlsitemap/translations" and add the default.pot to this folder - together with all available typical root folder translations files like "default.de.po" and "install.de.po". This xmlsitemap folder is currently not read by the core translation system and the reason is that the base xmlsitemap module is not in the root module folder. The default.* files are added by default to the uppermost translations folder of a module. They are "inheriting" strings to the other subfolders. To easily find translation files we have a hierarchy folder structures following some core rules.
Go to http://drupaler.ru/translate/languages/de/export?project=xmlsitemap and export the beta5 of xmlsitemap "Translation template" in "Drupal 6 package format" and you will see what will happen with l10n_server. l10n_server is planed to be the module that will be implemented on d.o for translation teams in future.
I'm out now.
Comment #22
avpadernoI don't see anything in Drupal.org that says xmlsitemap.module must be in xmlsitemap, rather than xmlsitemap/xmlsitemap; there is not the concept of base module too, in Drupal.org documentation. Plus, there is also another module that has the same structure of XML sitemap (see Rules).
As it's just one person to report this, are we sure it's the correct interpretation to give?
Comment #23
Anonymous (not verified) commentedAll truths are yet to be written; this truth has been implied. It is how 99% of all modules are written including those in core. Just because one module has set precedent doesn't make it correct.
Comment #24
avpadernoNor an implicit truth always is a real truth.
So far, what it has been said to be the way project.module will work has not been implemented, yet; then, we are depending on what reported by a single person.
If Project will be changed to automatically create the template files for the translations, then the directory structure can be changed (if it conflicts with the way Project works, but I still have doubts about that); until then, the only reference we have is the Drupal guidelines or standards, which doesn't state anything about the project directory structure used by XML sitemap being not correct.
There are two people who think the actual directory structure used by XML sitemap (or Rules) is correct versus one who thinks is not correct.
Most of the projects, then, contain a single module; in those cases, adopting a structure like the one I used would not have any meaning, as it would use a directory more without a real reason.
Comment #25
dave reidWhen in doubt, always follow the example set by core, which is root module directory contains the module files.
Comment #26
avpadernoDrupal core modules are not of help in this case.
To make an example, there is just a module, inside of modules/node (node.module); there isn't a node_extended.module too.
If I would take the example of the Drupal core modules, then I would create a different project for xmlsitemap.module, xmlsitemap_taxonomy.module, xmlsitemap_user.module, xmlsitemap_custom.module because differently I would have more than one module in a sub-directory of modules, which is not what Drupal core modules do. The directory structure that would put xmlsitemap_taxonomy.module in modules/xmlsitemap/xmlsitemap_taxonomy would not be used because none of the Drupal core modules uses a similar structure (there isn't modules/node/node.module, and modules/node/taxonomy/taxonomy.module).
In this case, what Drupal core modules do cannot be applied to third-party modules.
Comment #27
Anonymous (not verified) commentedI'm trying to determine the best way to handle a hook_update_N that will check for the existence of an xmlsitemap directory in the current module directory. I'm thinking that maybe an abort by throwing an exception is the best way to get the users attention. It doesn't look pretty but leaving the directory in place is asking for trouble and the module shouldn't be able to removed the directory on its own.
Maybe a hook_init that checks for the directory should also be created for this same abort.
Ideas please.
Comment #28
hass commentedFor what reason? We all Know we Need to delete old Files first and than extract a newer version. Nö Need for an update Hook at all.
Comment #29
hass commentedFor what reason? We all Know we Need to delete old Files first and than extract a newer version. Nö Need for an update Hook at all.
Comment #30
dave reidWe'll have to check if something like this would work:
Comment #31
Anonymous (not verified) commented@hass: For the reason that people don't do what they need to do. Just check this issue queue for the number of people who don't do what they're told. Posts complaining that they get errors about the nid column is missing in xmlsitemap_node or the tid column is missing in xmlsitemap_taxonomy just make my hair stand on end.
@Dave Reid: Thanks for the suggestion. I'll give it a try but throwing a exception from the hook_update_N is handled extremely well in the update.php script. I had to call the watchdog function before throwing the exception though. The message I created is a little more blunt stating that instructions were not followed and that if the instructions had been followed the situation causing issues wouldn't exist.
Comment #32
Anonymous (not verified) commentedIn xmlsitemap.module I have:
And in xmlsitemap.install I have:
A decision on the message string needs to be made. OASN: Drupal needs to standardize it's use of t(), why does watchdog not require it while drupal_set_message does. Hopefully this is addressed in D7 but I haven't the time to look.
Comment #33
avpadernoRather than using
hook_init()to output that error message, I would usehook_requirements().The proposed code would output that message for each page that is not cached (if the checked condition is true, indeed), without to verify if the currently logged in user is a user who has some administration roles; in other words, the message would be reported to any users who have an account on the Drupal site, even if they cannot solve the problem the message is reporting.
Comment #34
dave reidYes, please make it a hook_requirements check with REQUIREMENT_ERROR. That way, the user cannot install the module if the 'old' directory is still present.
Comment #35
Anonymous (not verified) commentedI will look at hook_requirements but I want this to be more obnoxious than an ice cube in Hell. Who better to get a sites' owner attention than the normal users of the system but I can filter the message to those who have administration access.
Comment #36
Anonymous (not verified) commentedHook_requirements isn't obnoxious enough. I want the idiot who installs without removing the previous directory to know immediately that there is a problem and with hook_requirements you have to go to admin/reports before you see the message. A user may have left the module active and installed as well and just overwrite the directory with the contents of the new package regardless of how many times you say otherwise, and thus thwarting the "cannot install" nicety. I've modified the hook_init like the following to address who sees the message issue.
Comment #37
avpadernoIt should be enough to check against a single permission; one of the Drupal standard permissions suits well enough the specific case to be used.
Users who have access to the reports could not have access to the installation directory, and users who can change Drupal actions could not be able to delete files from a remote site; maybe the users who can administer the site configuration can also be able to access the site directories but that is a supposition, which could not be true.
If not even the users with the permission to administer files have access to the remote directories of the site (or we can assume that it is normally true), then the only alternative is to use
hook_requirements(). I would not want that all the users of my site know details about the modules I installed, and I would not want they get any hint by an error message they read, and which is not destined to them.Comment #38
dave reidYeah, just use 'administer site configuration' please. :)
Comment #39
avpadernoNow that I thought more to what I said, I think that it should be used the same permission that allows a user to see the requirements page; looking at
system_requirements(), it's clear that the code shows an error message only when the user has the 'administer site configuration' permission.I guess that is the correct permission to use, as Dave already suggested.
Comment #40
hass commentedUsing hook_init() is tooo expensive... it's called on every page load :-(. But nevertheless I wouldn't care about stupid people. Simply close such issues without any comment or RTFM. Don't waste soooo much time one edge cases...
Comment #41
Anonymous (not verified) commentedThe main problem of this edge case is that the user can execute with no seeming issue. I will implement a hook_requirements instead of hook_init. IMO, it is more of a waste of time to spend responding to nonsense issues with RTFM and protecting the issue queue from idiots as much as possible is a good thing; but you're correct, wasting processing time isn't worth it.
Comment #42
Anonymous (not verified) commentedChange has been committed. http://drupal.org/cvs?commit=228264
Comment #43
hass commentedThx. Do not forget to move the translation files to the {root}/translations folder, please.