Translations in a theme
This page is for designers whose theme shows texts of its own ("Read more", "Search this site", button labels) and should work in more than one language. Writing the template side is explained in Translating template strings; here: the files in the extension.
The files
extension/mytheme/translations/
├── untranslated/translation.ts every source string, no translations (a template for translators)
├── ger-DE/translation.ts
└── fre-FR/translation.tssevenx_themes_simple ships eng-US, esl-ES, esl-MX, ger-DE, heb-IL, lat-VA, tlh-QO and untranslated;
sevenx_themes_media adds more, for example fre-FR, ita-IT, nor-NO and pol-PL.
Step by step
In templates, mark every text with a context of your theme:
{'Read more'|i18n( 'extension/mytheme' )}Create
translations/ger-DE/translation.tsin the Qt Linguist format with a<context>namedextension/mythemeand one<message>per text.Register the extension for translations in
extension/mytheme/settings/site.ini.append.php:/* #?ini charset="utf-8"? [RegionalSettings] TranslationExtensions[]=mytheme */Check the XML of every file:
xmllint --noout extension/mytheme/translations/*/translation.ts(no output expected).Clear the caches:
php bin/php/ezcache.php --clear-tag=ini --allow-root-userandphp bin/php/ezcache.php --clear-id=template,translation --allow-root-user.Open a siteaccess whose locale is
ger-DEand check the texts.
Good practice
- Keep one context per theme, so translators find everything in one place.
- Ship
untranslated/translation.tswith every source string, so a new language starts from a complete list. - Never repeat the same message twice in one context.
- A right-to-left language (
heb-IL,ara-SA) needs the layout to follow too (Right-to-left designs).
Related pages
- Languages
- Tutorial: internationalize a theme
- 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.