4

I'ld like to provide module specific translations for my custom modules. I followed the instructions in https://api.drupal.org/api/drupal/core!modules!locale!locale.api.php/group/interface_translation_properties/8.

But if I install the module no translations get imported. I've searched a lot for examples on the net, but it seems as no one else used it until now.

Here's my module "custom_module"

custom_module.info.yml:

name: 'Custom module'
version: '8.x-1.0'
core: 8.x
project: 'custom_module'
datestamp: 1434014760 
interface translation project: custom_module    
interface translation server pattern: modules/custom/custom_module/custom_module-%version-%language.po

and a "custom_module-8.x-1.0.de.po"-file with some messages in the module folder.

  • Hope this is helpful, please check out this link, zoubi.me/blog/drupal-translate-custom-module – latikas Jul 23 '15 at 7:12
  • Thank you latikas, but my question is about Drupal 8. I used the POTX module in several projects before (Drupal 7). – Seb Aug 3 '15 at 7:45
3

I had a similar problem that it didn't work but it turned out that my problem was with file permissions that weren't set correctly on the PO file I was trying to import.

I debugged it as follows:

On the following url admin/reports/translations you can see where it looks and what it looks for. (handy for debugging the tokens) Expand the status information for the available language.

Every time you change your info.yml file don't forget to rebuild cache and trigger the translation update manually.

1

did you manage to get this imported?

Your server pattern and file do not match (there is a '-' instead of a '.' in front of your %language in the server pattern). That might explain why it does not import on install...

I had some issues when the custom module was already installed. Changes to the server pattern in the info.yml did not propagate, so it would not find updates to my .po files

Finally managed it by clearing some state from the key_value table (delete from key_value where collection = 'state' and name = 'locale.translation_status';), clearing the cache, and then refreshing the translations.

Hope this helps,

Ewald

  • No I didn't get this to work. The filename pattern doesn't change anything. I've tested my module in a complete new Drupal8 Alpha14 installation again today. Seems like I have to wait until the documentation gets finished. – Seb Aug 18 '15 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.