TranslationSupplierBasedTranslator

class TranslationSupplierBasedTranslator(translationSupplier: TranslationSupplier, localeOrderDecider: LocaleOrderDecider, primaryLocale: Locale, fallbackLocales: List<Locale>) : ArgumentsSupportingTranslator(source)

Represents a Translator which uses a given TranslationSupplier to retrieve translations and a given LocaleOrderDecider to determine in which order it should try to find translations for a given Translatable.

Parameters

translationSupplier

The TranslationSupplier as such.

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 as well as the Locale which will be used in String.format, which in turn is used to substitute the placeholders in the resulting translation of TranslatableWithArgs.translatable with the TranslatableWithArgs.arguments.

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.

Constructors

Link copied to clipboard
constructor(translationSupplier: TranslationSupplier, localeOrderDecider: LocaleOrderDecider, primaryLocale: Locale, fallbackLocales: List<Locale>)

Represents a Translator which uses a TranslationSupplier to retrieve translations and LocaleOrderDecider to determine in which order it should try to find translations for a given Translatable.

Functions

Link copied to clipboard
override fun translate(translatable: Translatable): String

Returns the translation of the given translatable or its getDefault in case there is not a translation defined for it.