Translation¶
We manage translations as a part of the codebase using .po
translation files.
Consequently translations must be part of either official or local translations
to take effect on the individual site.
DPL CMS is configured to use English as the master language but is configured to use Danish for all users through language negotiation. This allows us to follow a process where English is the default for the codebase but actual usage of the system is in Danish.
Translation system¶
To make the "translation traffic" work following components are being used:
- GitHub
- Stores
.po
files in git with translatable strings and translations - GitHub Actions
- Scans codebase for new translatable strings and commits them to GitHub
- Exports translatable configuration strings into a separate
*.config.po
file - Merges the two files:
*.po
and*.config.po
into a*.combined.po
file - Notifies POEditor that new translatable strings are available
- When a project is exported from POEditor:
- The
*.combined.po
is split into two files:*.po
and*.config.po
- The
*.po
files are published to GitHub Pages
- The
- POEditor
- Provides an interface for translators
- Links translations with
.po
files on GitHub - Provides webhooks where external systems can notify of new translations
- DPL CMS
- Drupal installation which is configured to use GitHub Pages as an interface
translation server from which
.po
files can be consumed. - In the development setup and in cronjobs defined in the environments there are two jobs in charge of importing the regular translations and the configuration translations.
The following diagram show how these systems interact to support the flow of from introducing a new translateable string in the codebase to DPL CMS consuming an updated translation with said string.
case
sequenceDiagram
Actor Translator
Actor Developer
Developer ->> Developer: Open pull request with new translatable string
Developer ->> GitHubActions: Merge pull request into develop
GitHubActions ->> GitHubActions: Scan codebase and write strings to .po file
GitHubActions ->> GitHubActions: Fill .po file with existing translations
%% <!-- markdownlint-disable-next-line MD013 -->
Note over GitHubActions,GitHubActions: If config translations<br/>are available<br/>they are used<br/>otherwise empty strings
%% <!-- markdownlint-disable-next-line MD013 -->
GitHubActions ->> GitHubActions: Exports configuration translations into a .config.po file
%% <!-- markdownlint-disable-next-line MD013 -->
GitHubActions ->> GitHubActions: The two .po files are merged together into a .combined.po file
GitHubActions ->> GitHub: Commit combined.po file with updated strings
GitHubActions ->> POEditor: Call webhook
POEditor ->> GitHub: Fetch updated combined.po file
POEditor ->> POEditor: Synchronize translations with latest strings and translations
Translator ->> POEditor: Translate strings
Translator ->> POEditor: Export strings to GitHub
POEditor ->> GitHub: Commit combined.po file with updated translations to develop
GitHub ->> GitHub: .combined.po is split into two files: .po and .config.po
GitHub ->> GitHub: All the po files are published to Github Pages
DplCms ->> GitHub: Fetch .po file with latest translations
DplCms ->> DplCms: Import updated translations
DplCms ->> GitHub: Import config.po file with latest configuration translations
Howtos¶
Add new or update existing translation¶
- Log into POEditor.com and go to the
dpl-cms
project - Go to the relevant language
- Locate the string (term) to be translated
- Translate the string
Publish updated translations¶
- Log into POEditor.com
- Select the "Settings" tab
- Click the GitHub code hosting service
- Check the relevant language(s)
- Select "Export to GitHub" and click "Go"
Import updated translations¶
- Run
drush locale-check
- Run
drush locale-update
Import updated config translations¶
Run drush dpl_po:import-remote-config-po [LANGUAGE_CODE] [CONFIGURATION_PO_FIL_EXTERNAL_URL]
Example: