doc / ch.tutteli.atrium.reporting.translating / ArgumentsSupportingTranslator

ArgumentsSupportingTranslator

abstract class ArgumentsSupportingTranslator : Translator (source)

Represents a Translator which supports TranslatableWithArgs.

Therefore, it provides a default implementation for translate but in turn defines an abstract method translateWithoutArgs which sub-classes have to implement.

Constructors

<init>

ArgumentsSupportingTranslator(primaryLocale: Locale, fallbackLocales: List<Locale>)

Properties

fallbackLocales

val fallbackLocales: List<Locale>

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.

primaryLocale

val primaryLocale: Locale

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.

Functions

translate

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.

translateWithoutArgs

abstract fun translateWithoutArgs(translatable: Translatable): String

Do not call this method in case you want to translate a TranslatableWithArgs use translate in this case.

Inheritors

TranslationSupplierBasedTranslator

class TranslationSupplierBasedTranslator : ArgumentsSupportingTranslator

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.

UsingDefaultTranslator

class UsingDefaultTranslator : ArgumentsSupportingTranslator

This translator does not translate but uses Translatable.getDefault instead and uses getDefaultLocale as primaryLocale if not defined differently via constructor parameter.