We use the "translation server" stuff from the Interface Translation module for translations, i.e. all module and theme .info.yml files contains something like
"interface translation project": «module/theme name»
"interface translation server pattern": «modules|themes»/custom/%project/translations/%project.%language.poand each module/theme has a translations folder containing .po files with translations.
The translations can be imported via Drush by running these commands:
drush locale:check
drush locale:update
drush cache:rebuildTo make life a little easier, all this1 can be done by running
task translations:importWe use the Translation extractor module to extract translations from code (PHP and templates) in (custom) modules and themes.
Note
The Translation extractor module is only needed (and hence only installed) during development and therefore it's also
excluded from configuration synchronization in settings.php:
# web/sites/default/settings.php
$settings['config_exclude_modules'][] = 'drupal_translation_extractor';Update module and theme translations by running
task translations:extractSee includes.translation in ../Taskfile.yml and the included
Taskfile for details and the list of custom modules and themes that we extract
translations from (it may not make sense to do it for all custom modules and themes).
Use task translations:diff to check for any changes. New (or empty) translations are marked as
"fuzzy" and default Danish translations for
these must be added.
Tip
Poedit is an excellent tools for editing po files.
Footnotes
-
Plus any additional project specific translations. ↩