abstract fun newTranslator(translationSupplier: TranslationSupplier, localeOrderDecider: LocaleOrderDecider, primaryLocale: Locale, vararg fallbackLocales: Locale): Translator
(source)Creates a Translator which translates Translatables to primaryLocale and falls back to fallbackLocales (in the given order) in case no translation exists for primaryLocale.
It uses the given translationSupplier to retrieve all available translations. In case no translation exists for a given property (neither for the primaryLocale nor for any fallbackLocales) then it uses Translatable's getDefault. As consequence a Translator does not or rather should not support Locale.ROOT -- users are discouraged to define properties files for Locale.ROOT. An implementation based on ResourceBundle would still take Locale.ROOT into account but apply it before the defined fallbackLocales have been considered.
Please refer to the documentation of Translator to see to which extend a translator has to be compatible with ResourceBundle.
translationSupplier
- Provides the translations for a desired Locale.
localeOrderDecider
- Decides in which order Locales are processed to find a translation for a
given Translatable.
primaryLocale
- The Locale to which the translator translates per default.
fallbackLocales
- Used in case a translation for a given Translatable is not defined for primaryLocale
or one of its secondary alternatives -- the fallback Locales are used in the given order.
IllegalArgumentException
- in case primaryLocale or fallbackLocales have as language no
or if they
have: as language zh
, country is not set and script is either Hant
or Hans
.
Return
The newly created translator.