Updating Interface Translations
Interface translations for WissKI modules live next to each module as Gettext
.po files under translations/. German (de) translations are maintained in
the repository.
When source strings change (new t() calls, changed labels, removed text),
those .po files need to be refreshed so translators can see new and obsolete
strings without losing work that is already done.
Refreshing .po files¶
Inside the WissKI devcontainer, the potx module is available as a development dependency. From a site with Drush and potx discoverable, refresh translations for one module, several modules, or every non-legacy WissKI module.
Refresh a single module:
drush wisski-devel:update-translations wisski_core
Refresh several modules in one run:
drush wisski-devel:update-translations wisski wisski_core
Omit the module arguments to refresh every discovered module under the WissKI
package root except those in legacy/:
drush wisski-devel:update-translations
For each module, the command:
- Extracts the module's current translatable strings via potx PHP APIs (nested
modules and non-source trees such as
tests/are skipped). - Prints any potx translatability warnings collected during that pass (for
example non-literal
t()/ logger messages, or empty localized strings)..poupdates still proceed. - Merges that extraction into every existing
translations/*.pofile under the module, keeping translations whose source strings still match. - Drops entries that are no longer present in the sources (unless you pass
--keep-orphans). - Appends newly extracted sources with an empty
msgstr. - Creates
translations/{project}.de.powhen the module has no.pofiles yet ({project}comes frominterface translation projectin the module info when set, otherwise the machine name).
To retain manual or shared entries that potx does not extract from a module's sources (for example a “Common terms” section), run:
drush wisski-devel:update-translations wisski_core --keep-orphans
--keep-orphans applies to every module processed in that run.
After running the command¶
Review the resulting Git diff:
- New
msgidentries need a German (or other)msgstr. - Removed entries were dropped because they are no longer in the module
sources (unless
--keep-orphanswas used). - Formatting of long strings and
POT-Creation-Datemay change even when translations did not; that is expected.
Commit the updated .po files together with the code change that introduced
the new or changed strings.
This command only updates the files in the repository. Importing them into a
running site's translation database is a separate step (for example
drush locale:import).