Class Messages
The catalogue itself lives in autumo-ui: Helper.getMessageBundle(…) resolves the
gettext PO files (lang/messages.<lang>.po, see
PoResourceBundle) first and falls back to the framework bundle for
the framework's own keys. This class therefore only adds the conventions that go beyond
that lookup:
- the message id of an untranslated text is the English text itself (gettext
convention), so
t(String, BaseApp)falls back to the id; t(String, String, BaseApp)lets metadata-driven texts (parameter labels, help texts) be translated by their raw configuration key while the English label stays the fallback;format(String, BaseApp, Object...)appliesMessageFormatand survives a malformed pattern;setLanguage(String, String)selects the language and reports how many entries the catalogue carries.
The language is resolved once at start-up (see BaseApp.resolveLanguage(java.util.Properties):
request parameter, configuration, desktop language) and can be switched at runtime.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic Stringstatic StringThe active language code, e.g.static intsetLanguage(String lang, BaseApp app) Switches the application language via the framework.static intsetLanguage(String lang, String basePath) Switches the application language via the framework.static intNumber of entries the PO catalogue of the active language carries.static intNumber of entries the PO catalogue of the active language carries.static StringTranslatesidand returnsiditself when it is not translated.static StringTranslatesidand returnsiditself when it is not translated.static StringTranslatesidand falls back toenglishwhen there is no translation.static StringTranslatesidand falls back toenglishwhen there is no translation.
-
Field Details
-
LANG_EN
The source language of the application; also the fallback for missing translations.- See Also:
-
-
Method Details
-
getLanguage
The active language code, e.g.enorde.- Returns:
- plain ISO 639-1 language code
-
setLanguage
Switches the application language via the framework.A region is ignored (
de_CHandde-CHboth select German) and unknown or blank values fall back to English, exactly likeHelper.setLanguage(String). The framework also moves the JVM default locale and theuser.languagesystem property, so framework bundles and the per-language About HTML follow the choice.- Parameters:
lang- language code, e.g.enordeapp- base app- Returns:
- number of translations in the catalogue (0 for English apart from the framework-key overrides)
-
t
-
t
Translatesidand falls back toenglishwhen there is no translation.This is what the metadata-driven parameter labels use: their message id is the raw configuration key (e.g.
data_path) and the fallback is the English label the code derives from that key ("Data path"). A catalogue can then translate the parameter by its key, and everything that is not translated stays as it is.- Parameters:
id- message id, e.g. the raw configuration keyenglish- English fallback textapp- base app- Returns:
- translated text or
english
-
format
- Parameters:
id- message idapp- base appargs-MessageFormatarguments- Returns:
- formatted text; the raw pattern when it is malformed
-
size
Number of entries the PO catalogue of the active language carries.English is the source language and ships only the framework-key overrides, so a value of 0 means "no catalogue at all" (unknown language).
- Parameters:
app- base app- Returns:
- number of translated messages
-
setLanguage
Switches the application language via the framework.A region is ignored (
de_CHandde-CHboth select German) and unknown or blank values fall back to English, exactly likeHelper.setLanguage(String). The framework also moves the JVM default locale and theuser.languagesystem property, so framework bundles and the per-language About HTML follow the choice.- Parameters:
lang- language code, e.g.enordebasePath- base path, e.g. "ch/autumo/ui"- Returns:
- number of translations in the catalogue (0 for English apart from the framework-key overrides)
-
t
-
t
Translatesidand falls back toenglishwhen there is no translation.This is what the metadata-driven parameter labels use: their message id is the raw configuration key (e.g.
data_path) and the fallback is the English label the code derives from that key ("Data path"). A catalogue can then translate the parameter by its key, and everything that is not translated stays as it is.- Parameters:
id- message id, e.g. the raw configuration keyenglish- English fallback textbasePath- base path, e.g. "ch/autumo/ui"- Returns:
- translated text or
english
-
format
- Parameters:
id- message idbasePath- base path, e.g. "ch/autumo/ui"args-MessageFormatarguments- Returns:
- formatted text; the raw pattern when it is malformed
-
size
Number of entries the PO catalogue of the active language carries.English is the source language and ships only the framework-key overrides, so a value of 0 means "no catalogue at all" (unknown language).
- Parameters:
basePath- base path, e.g. "ch/autumo/ui"- Returns:
- number of translated messages
-