Closed (won't fix)
Project:
Localization update
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 Feb 2012 at 13:23 UTC
Updated:
10 Mar 2014 at 11:30 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sutharsan commentedA translations directory per module is no longer supported since drupal.org moved to git. Either use the common translations directory or setup your own translation server using the Localization Server module and configure the location of this server in the .info file of your custom module. See README.txt and l10n_update.api.php for info.
Comment #2
Tor Arne Thune commentedThat's what I was trying to say. I am trying to move away from having the translation files in the module directory, but putting them in the defined (common) directory for translation files doesn't work. l10n_update doesn't find the files there for custom modules. l10n_update does, however, find the translation files in this directory for contributed modules and core, so I thought it was strange that it doesn't work the same for custom modules.
Comment #3
Tor Arne Thune commentedThe bug, basically:
I have a custom module in
sites/all/modules/customWhen I place translation files for this module under
sites/all/modules/custom/module/translationsthey are found by l10n_update and imported. But I want to avoid using this directory.To avoid using this directory I try to place them under
sites/all/translations, but they are not found by l10n_update.sites/all/translationsis the common storage directory I have defined for the Drupal installation and where all other translation files for contributed modules and Drupal core are found and imported.Translation files are found and imported by l10n_update from
sites/all/translationsfor all contributed modules, but not for my custom modules (that are also enabled for the site).Comment #4
sutharsan commentedHave you used the syntax as described in the README.txt? Note that this requires the custom module to have a version.
I was not aware that po files in module/translations were still processed. But that may be done by core.
Comment #5
Tor Arne Thune commentedAh, I need to define a l10n server for custom modules? I thought it was enough to put the translation files in the defined common translations directory and l10n_update would find it there.
The custom module's info file:
Comment #6
sutharsan commentedYou can do one or the other. For this module a po file named
copyright_block-7.x-1.0.fr.po(for French translation) in the common translation directory should do the trick. See the README.txt.Comment #7
Tor Arne Thune commentedYes, that's what I have:
When I install and try to import translations for the enabled modules:
Comment #8
sutharsan commentedCan you try again with the latest dev version. I think you're not using the latest.
Comment #9
Tor Arne Thune commentedSure.
When I install and try to import translations for the enabled modules:
I can see in the watchdog table (and by looking at the site UI) that all modules have been translated (except for dev version of l10n_update of course) except the custom module copyright_block.
Comment #10
sutharsan commentedI can't reproduce this, manually (Update translation/Refresh information) via the Translation Update page nor using Drush. Or when enabling the module via drush. In all situations the file is detected and imported.
You have to debug the code to find the problem. Some suggestions:
$filenameinl10n_update_source_check_file()contains the file name being looked for.l10n_update_source_build()this file name is composed based on information in$project.Comment #11
Tor Arne Thune commentedThese are the exact steps I use to reproduce the bug:
Result:
Comment #12
sutharsan commentedOk, lets call it an undocumented feature ;) l10n_update ignores modules that don't have a project definition in the info file. All d.o files have one and have translation files available at l.d.o. Unreleased modules have none, custom modules either. And usually these don't have translation files associated. Add
project = copyright_blockto the info-file and it will be processed.Note @self: Need to update documentation with this.
Comment #13
Tor Arne Thune commentedAhh, that did the trick. Thanks for looking into this. I would not have guessed to add this line. Now I can move my translation files for custom modules to the common translation directory and be more ready for Drupal 8. One translation directory to rule them all.
Comment #14
sutharsan commentedInstead of 'project = xyz' I was thinking of something like 'l10n-update-source = local'.
Comment #15
Tor Arne Thune commentedI have discovered an unfortunate side-effect of having 'project = ...' in the info file for custom modules. With this line, Drupal will search for updates to the module on Drupal.org, just as with contributed modules. The result is that if the custom module has the same name as a project on Drupal.org, Drupal will propose updates to the module if they exist for the contributed module with the same name.
Comment #16
sutharsan commentedIs is my practice to prefix custom modules with the project or customer name (abbreviation). But that's just a side node and not meant to solve the case.
This attached patch requires an entry in the .info file like:
I'm not sure yet if a change in the info file is the best way. The alternative is this hook, which is not very elegant either.
Comment #17
Tor Arne Thune commentedI must say I prefer the added property in the info file. My motivation for not prefixing the custom module name was that I wanted to create a common custom module that could be used across all projects I have, as I have all projects in one multi-site installation.
Adding the 'l10n project' property to the info files of custom modules that have translation files would be a fairly painless requirement for translation of custom modules. As long as it is documented that this is a requirement for the translation of custom modules, I don't think it would cause problems. As I've understood, translating custom modules is not a very common task, anyway.
Comment #18
sutharsan commentedDocumentation added.
If more people support this patch, it will be added to the module.
Comment #19
Tor Arne Thune commentedHow about this: Use the file name of the info file when the the project name can't be guessed by info file properties.
This would avoid having to add a l10n_update-specific property to the info file of custom modules.
The core Update module didn't do this in their
update_get_project_namefunction because it wouldn't make sense to search for updates to custom modules (modules without a project property defined) on Drupal.org. For l10n_update it would make more sense, as l10n_update has the option of discovering translation files in a locale storage location.Comment #20
tangent commentedI need similar functionality. It isn't clear if the "import" provided here is one time or if modifications to local po files are reloaded after the first time. I needed the ability to reload translations for custom modules and themes so I made my own module (for D6) with a drush command to support this. I will investigate further if l10n_update for D6 supports my requirements.
Comment #21
gábor hojtsyIt should definitely support it, no custom module required.
Comment #22
tangent commentedI've read the README.txt (6.x-1.x branch) and it doesn't mention local po files but only alternative update servers.
I currently host my custom component translations in /sites/all/modules/custom/module/translations or /sites/all/themes/theme/translations and found that l10n_update doesn't do anything with these. I've tried placing a po file in /sites/all/translations and using the drush command to update again but it was not found there either.
When you say "it should support it" do you mean now or at some future stage? What am I doing wrong if it's supported? Do I need to add a "l10n path" in the info file or something? That seems rather clunky.
Comment #23
gábor hojtsy@tangent: have you set up your info file as discussed above for your custom module?
Comment #24
tangent commentedIt is not obvious, based on the README file, that any change needs to be made to the info file for local po files. What should be added? Something like the following? Are relative paths supported? Absolute paths would be a big issue for testing in different environments.
l10n path = /sites/all/translations/module.poComment #25
gábor hojtsy@tangent: once again, have you read the comments above? Specifically #12?
Comment #26
tangent commentedYes, the module info has a project line. It doesn't show up on the update page though.
I discovered that the update settings were set to "remote only" though so I changed that to local and remote but still no joy.
Comment #27
Tor Arne Thune commented#12 has some unwanted side-effects if the custom module name is the same as a project on Drupal.org, as the Update module would try to find updates for the custom module, on Drupal.org. I think your best bet would be to apply Sutharsan's patch in #18 and adding
l10n project = your_custom_moduleto the .info file of your custom module. This will allow l10n_update to find translation files for your custom module in the specified translations directory (usually sites/all/translations).Comment #28
sutharsan commented@tangent, This issue is about 7.x. But in 6.x this problem exists too. Patch in #18 is for 7.x. We should first agree on what a good solution is. In any case there will only be one translations directory for all (contib modules, contrib themes, custom modules, profiles, etc.).
Comment #29
tangent commented@Sutharsan, thanks for the reminder about the version. I've tried the patch, with a manual edit, and it didn't have any effect that I can see. I've added the "l10n project" line to my info but the module still does not appear in the update page (admin/build/translate/update). I added a dpm() statement at the top of the _l10n_update_project_info_list() function but there is no output on the update page so I don't know what to make of that.
My current solution, a module based on l10n, works well for me because of my use case. All of the translations for our site are in code because that's easier to deploy and manage. I can "reload" translations with my module independently of updating remote translations. It almost seems like 2 different use cases to me but only because community translations for contrib modules are less urgent and local translations for custom modules are critical. The site is a fully bilingual goverment website by the way.
Comment #30
tangent commentedOk, I discovered that I have to use "Refresh information" to get to that code block modified by the patch and my custom module is appearing in the list now. Updating works once but modifications to the po file do not show up as updated in the list. In the module info file the version is set to "6.x-1.x-dev" but presumably it uses the version to know if it should check for an update? What should we use for a version for custom modules so that l10n_update knows to check for changes? I have not bothered with module/theme versions before and I would rather not start.
Comment #31
tangent commentedCan I suggest adding a new drush command "l10n-reload" to force updating translations from local files only and leave the "l10n-update" to update remote translations? That's what my module does (the l10n-reload command). I'll attach my modules drush.inc file for review or inclusion.
Comment #32
sutharsan commented@tangent, please create a new issue for this. The issue will get closed when the original problem is fixed and your suggestion may get lost. I'm not sure it this is the right solution for the problem. 1. Consider extending the drush command l10n-update with options to update individual projects and to force using local files. 2. Is the local module not updated due to caching? Checking for updates is expensive, therefore a minimum cache life time of one hour is used. A day of week life time is used depending on you settings. 3. The file time stamp is used to determine the change date.
Comment #33
sutharsan commented@Tor Arne Thune, your #19 patch causes all modules which are no project to show up on the Translation Update page. Try the patch and you will see :)
I see two directions:
A flag in the .info file to indicate the module has a local translation file
An alter hook with which the module makes itself known (after being ignored by _l10n_update_project_info_list().
http://drupal.org/node/1329410 touches the same case for Drupal 8
Comment #34
SuleymanK commented#18 works fine. I needed this to translate features generated code. Thanks.
Comment #35
trickfun commentedI have the same problem with the new multilanguage version of my project www.riparotto.com
the .po file of my custom module is imported but no translation is done
No problems loading the po file from the interface, I upload the file and the translation is ok
configuration:
my ripa_user.info file:
drush log:
process deletes 14 string and no translation is done.
why?
Comment #36
wusel commentedI use:
D7.17 in German
Localization update 7.x-1.0-beta3+3-dev
There are three typos in the file "
l10n_update.inc" in the new part offunction l10n_update_http_check:please change
$uri)to$url)(lines 275, 278 and 281). This is why I have changed the Category to bug report. Please feel free to re-change.After that I have installed and enabled http://drupal.org/node/1285276 (Import new users and their Profile2 fields from one CSV file) with the file "
sites/all/modules/a_wusel_migration/translations/a_wusel_migration-7.x-1.1.de.po" and added the lineproject = A Wusel Migrationin the .info file.
Now Localization update cannot find the language file.
Then I have added a line with the correct "
l10n path = <path>"-line in the .info file (path beginns with "http://"). Now I get the error "HTTP error 403 occurred when trying to check <path>".I think, the "
.htaccess"-file in the root of the drupal-server stops this path because the.pofiles are stopped:If I delete "
po|" in the ".htaccess"-file in the root of the drupal-server, Localization update finds the.pofile.I think, if the "
l10n path" is the same server as our drupal-server, we have to catch the.pofiles directly.Wusel
Comment #37
sutharsan commentedFor custom module you need to put the po file in the translations directory with file name matching the pattern: [project name]-[version].[language code].po
Translations directory set at: admin/config/regional/language/update. Project name should not contain spaces.
Back to feature request. The bug wusel reported is already fixed.
Comment #38
wusel commentedI agree to #14 and #15.
From "Writing module .info files (Drupal 7.x)" (http://drupal.org/node/542202):
#38:
Many project names have spaces. My link in #36 too. Sorry.
To improve this great module, it would be nice to have a local solution. Something like
Thank you very much.
Wusel
Comment #39
sutharsan commentedThere are two kinds of module names. The system name and the human readable name. I refer to the first. If you define a 'project' in the info file, Update module will also attempt to check for update info at d.o.
For implementation of l10n_update in Drupal 8 we have chosen for two optional parameters in the .info file:
For custom module with a local translation file you could do:
or
If time permits this will be backported to Localization Update module.
Comment #40
wusel commented@Sutharsan:
An backport to D7 would be nice to test this for D7.
Thank you very much.
Wusel
Comment #41
frank ralf commented@#4
When l10n Update is disabled core seem to still pick .po files from custom modules /translations subfolders when installing the module which IMHO is a desired behavior because it's a very maintainable solution for small projects with only a handful of translatable strings.
Comment #42
osopolarPatch in #18 works fine and seems to be a good solution (in terms of #28). I don't think that we need to wait for the backport from d8.
The option "interface translation server pattern" is by design defined as described in the README, it's not necessary to make it configurable. The option "interface translation project" in #18 is called l10n project, which seems to be fine, because its the modules namespace.
Comment #43
sutharsan commentedThe 8.x code has been backported and is available as 7.x-2.x release. The .info file strings used in 7.x-2.x are different from the ones suggested in #18. It will be bad development experience if we introduce a new feature in 7.x-1.x which we know will break when migrating to 7.x-2.x or 8.x. Automatic migration from 1.x to 2.x is not possible for this kind of strings in the .info file. In my view it is best to no introduce this in 7.x-1.x and therefore I will close the issue. Feel free to disagree and to reopen the issue to continue the discussion.