Drupal translate custom module
If you created your custom Drupal module and you wonder how to translate it in other language then you came to the right place!
In few simple steps I ll show you how to export translatable strings from your custom module and import them in Drupal translation interface.
- Download and install the Translation Template Extractor (POTX).
- Use POTX to extract from the installed module a .pot template, that is, a file that includes the untranslated strings in english.
- Download and install POEdit, the most common string translator.
- Use POEdit to create, from the extracted .pot template, the other language version of the strings, a file with the .po extension (for example es.po for Spanish translation).
- Create a translations folder within your your module, e.g. example_module/translations
- As a base for other translations, place the .pot file (example_module.pot) which you created in step 2. above within the translations folder. example_module/translations/example_module.pot
- Place the extracted .po from step 4. there as e.g. es.po for a Spanish translation. example_module/translations/es.po
Note that Drupal will only read in translation files on initial install of the module, so you will have to reinstall the module or you can also go to the translation interface menu and click on the import tab and load your .po file directly.