I cannot find any good examples on how to make a module configuration translatable. Could someone give me a starter example to build off with?

  • You should definitely read this tutorial: hojtsy.hu/blog/2014-may-26/… . It's part of a series of tutorials for multilingual Drupal 8 development by the same author. Highly recommended. – CamilB Jul 9 '17 at 9:36

In config there are only few field types that are translatable by default text, label and i think date_format(you can check the schema types to see which field types exactly are translatable by default). You can also make any value translatable by adding the translatable: true flag to the field. Now, copy your config/install directory into config/install/language/LANGCODE and edit each one of those config files and keep only the translatable fields..and translate those :)

If you want to provide translations for you module so t() function will pick them up, that is a bit strange in D8 compared to D7 but to put it simply you have to edit your module's info file and put in the following lines:

'interface translation project': yourprojectname
'interface translation server pattern': relativepathtotranslationsdirectory/%project-%version.%language.po
  • Shouldn't the translation folder be config/install/language/LANGCODE instead? – CamilB Jul 8 '17 at 10:34
  • You are correct, I have updated my answer. – user21641 Jul 9 '17 at 6:15

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.