I have a custom module whose interface strings have all been written in English. This module is not (and will not be) hosted on drupal.org, so I'd like to pack the translations for those texts directly with the module, and for those translations to be automatically imported by Drupal when the module is installed (provided the corresponding language is activated in Drupal, of course).
I've translated those texts in French and exported all those translations in a my_module-fr.po
file. I've put this file in the "translations" folder inside my module folder.
As suggested in this answer, I used the interface translation properties in the my_module.info.yml
, as follows:
'interface translation project': my_module
'interface translation server pattern': modules/custom/my_module/translations/my_module-%language.po
But when I install my module from scratch, those translations are not automatically imported.
In admin/reports/translations
, it says "Missing translations for one project - my_module (1). File not found at modules/custom/my_module/translations/my_module-fr.po".
I've tried several variations for the interface translation server pattern
value in the info.yml file, among them:
- path relative to the module folder (
translations/my_module-%language.po
) instead of the Drupal folder - full path to the drupal install folder (since I'm on localhost and Drupal is in a subfolder) (
_tests/drupal8/www/modules/custom/my_module/translations/my_module-%language.po
)
But I always get the same "file not found" message in the admin report page, and nothing is imported.
What am I missing?
Side question: in the YML declaration above, is it allowed to use a path pattern relative to the module folder, as listed above? This would make a lot more sense to me, as I cannot predict whether the people will install my module in the "modules/contrib" folder, or in another subfolder, or directly in the "modules" folder (and if they install it from the Drupal UI, they may not even know it themselves).