I maintain several drupal 8 websites using the same instance. They all uses a custom module I developed.
I have a .po file containing the translations I need. I can import them using the admin interface and all is well.

How can I setup automatic import of the module .po file ? And trigger the update/import on all websites when the .po file is updated ? I've spent much time in the drupal 8 documentation to no luck, unfortunately.

I've tried putting the .po file in various location on the filesystem : modules/modulename/files/translations/ or sites/websitename/files/translations are not working. Even when I enable local translations and launch a manual translations update.

Thank you for your help!

Comments

gaboo’s picture

Obviously, after posting this I've finally found a solution.
I post it here hoping the next me might find it useful.

I've used this drush plugin : https://github.com/dawehner/drush_language
Put the file in sites/all/drush/drush_language/

drush cc drush
drush language-import fr yourfile.po
drush cr
gaboo’s picture

I've looked into this a little bit more after tstoeckler on GitHub told it should work using drupal 8 core locale update tools (https://github.com/drush-ops/drush/issues/139#issuecomment-215581536).

Indeed, it works. What is needed though :

  • the project module.info.yml file needs to contain a project name : project: projectname
  • the po file needs to be named according to module version : projectname-0.1.fr.po
  • the po file needs to be placed in sites/sitename/files/translations. It does not work anywhere else (module directory or sites/all/translations in particular)

The module project name part is very hard to find out. Everything works, no error message or problem anywhere apart from the fact that translations are not found.

Finding this all by yourself by experimenting is tedious and feels it should be way more easier. No documentation about that anywhere I've looked for. Hoping again this post will help other people save time.

handkerchief’s picture