Translating template strings
This page is for designers who prepare a theme's texts for translation and maintain the translations. For the step-by-step first time, see Tutorial: internationalize a theme.
Contents
- From template to translation
- Where theme translations live
- Writing good source texts
- Checking and caches
- Fallbacks
From template to translation
- A template prints
{'Read more'|i18n( 'design/mytheme/line' )}. - The translation file of the locale has a
<context>nameddesign/mytheme/linewith a<message>whose<source>is exactlyRead more. - Its
<translation>is shown; without one, the source text is shown.
Where theme translations live
extension/mytheme/translations/ger-DE/translation.ts
extension/mytheme/translations/fre-FR/translation.ts
extension/mytheme/translations/untranslated/translation.ts (optional: every source, empty translations, for translators)The siteaccess reads them when site.ini [RegionalSettings] TranslationExtensions[] lists the extension. The media
theme ships eleven catalogues in this layout; the starter theme ships ger-DE. See
Translations in a theme.
Writing good source texts
- Whole sentences with placeholders, never fragments joined in the template.
- One meaning per context: "Open" (a verb on a button) and "Open" (a state) in different contexts.
- A comment for translators when the text is ambiguous (the second
i18nparameter). - American English source texts ("color", "license"), as in the rest of the product.
Checking and caches
./console exp:ezchecktranslation ger-DE # statistics for one translation
php bin/php/ezcache.php --clear-id=translation # after changing a .ts file
xmllint --noout extension/mytheme/translations/ger-DE/translation.tssite.ini [RegionalSettings] TranslationCache=enabled caches translations; TranslationCheckMTime=enabled (default)
notices changed .ts files by their time.
Fallbacks
A locale can fall back to another for missing texts (for example a regional variant to the main language);
./console exp:i18n fallbacks shows each locale's chain and how much of the kernel and of each extension it shows
translated (doc/eng-us/languages.md, "Translation fallbacks").
Related pages
- The i18n operator
- Languages in Exponential
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.