doc / ch.tutteli.atrium.core / CoreFactoryCommon / newTranslator

newTranslator

abstract fun newTranslator(translationSupplier: TranslationSupplier, localeOrderDecider: LocaleOrderDecider, primaryLocale: Locale, fallbackLocales: List<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.

Please refer to the documentation of Translator to see to which extend a translator has to be compatible with Java's ResourceBundle.

Parameters

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.

Exceptions

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.