Updating translations from local files is currently problematic, based on my testing. It is also impossible to update only from local .po files which is essential for a multi-lingual website with custom modules or themes.
I propose adding a drush command or command switch to allow reloading translations from local files. I have created my own custom module (for D6) to fulfill this requirement because I was unable to achieve the same result with l10n-update, even with suggested .info file options. Attached is the drush.inc portion of my custom module which creates a new command, 'l10n-reload'.
It was suggested in #1430004: Custom modules are ignored that a switch should be added to the existing l10n-update command instead.
| Comment | File | Size | Author |
|---|---|---|---|
| locale_extras.drush_.inc_.txt | 2.47 KB | tangent |
Comments
Comment #1
sutharsan commentedA simple trick to force reload of local files it to change the timestamp of the file in the translations directory. If you combine this with changing the translation source to local, you can update the translation using locally stored po files.
Comment #2
tangent commentedCan you clarify what you mean by "changing the translation source to local"? I assume you mean the l10n * properties in the module info file. I haven't had any luck with these properties, in that my custom module does not show up on /admin/build/translate/update (l10n_update). I'm testing on D6 fwiw.
Comment #3
sutharsan commentedAt admin/settings/language/update you have the option to set the 'Update source' to 'Local files only'.
To have your custom module show up in the list of translatable projects, it needs a 'project' setting in the .info file.
Comment #4
tangent commentedI have update configured with the "Local files and remote server." option which I assume should also work. Unfortunately, it does not as far as I can tell. Ensuring the 'project' setting in the module info file does get the module to show up but with "No information" instead of a translation status.
I've tried every variation imaginable between the update api (hook_l10n_update_projects_alter) and adding the 'l10n server', 'l10n path' settings to the info file but the module translation always shows "No information". I'm confident I could force it to work by have the module provide its own custom localization update server so that it could update itself but this seems way outside of the intended use of the API and my current drush plugin is far more general.
Am I missing something here?
Comment #5
sutharsan commentedI've got a custom project translated using the following steps:
- Included a 'project' definition in the .info file (see below)
- Copied the po file of the example module into the translations directory (default: sites/all/translations) with the name
example-7.x-1.0.nl.po.- Hit the 'Refresh information' button at admin/config/regional/translate/update. The local file is detected and listed.
- Hit the 'Update translation' button and the translation gets imported.
Comment #6
tangent commentedThank you @Sutharsan, that was what I needed. I had to move my translation files to sites/all/translations and add "version" and "project" properties to the info file and now it's working great. Thanks for the instruction.
Closing this since I'm satisfied with the solution.