Translations¶
Every user-visible string a plugin shows must be translatable, with catalogs for
all four supported languages — en, pl, de, fr — before the plugin is
considered done. This is the same bar as tests.
Catalogs¶
Each plugin that has any string carries one .ts catalog per language under its
Translations/ folder:
Wire them into the build via mte_add_plugin:
mte_add_plugin(NAME MyPlugin
SOURCES Src/MyPlugin.cpp
TRANSLATIONS
Translations/MyPlugin_en.ts
Translations/MyPlugin_pl.ts
Translations/MyPlugin_de.ts
Translations/MyPlugin_fr.ts
)
The build runs lrelease to stage .qm files; TranslationManager loads them
by catalog name at runtime (plugin catalogs under
Plugins/Translations/<Plugin>/).
Marking strings for translation¶
- Prefer
QObject::tr(...)(context = the class) for normal UI strings. - The
tr_()helper wrapsQCoreApplication::translate("<Context>", s)for strings outside aQObject.
tr_() is invisible to lupdate
lupdate cannot resolve the context inside tr_(), so those catalogs are
maintained by hand. Keep the <source> text byte-identical to the
runtime string, or the translation silently won't apply.
Definition of done¶
A plugin's localisation is done only when all four .ts files exist, are wired,
and lrelease reports 0 unfinished strings.