atrium-impl-robstoll / ch.tutteli.atrium.reporting.translating / ArgumentsSupportingTranslator

ArgumentsSupportingTranslator

abstract class ArgumentsSupportingTranslator : ITranslator

Represents an ITranslator which supports ITranslatableWithArgs.

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)

Properties

primaryLocale

val primaryLocale: Locale

The Locale to which the translator translates per default as well as the Locale which will be used in java.lang.String.format, which in turn is used to substitute the placeholders in the resulting translation of ITranslatableWithArgs.translatable with the ITranslatableWithArgs.arguments.

Functions

translate

fun translate(translatable: ITranslatable): 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: ITranslatable): String

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

Inheritors

ResourceBundleBasedTranslator

class ResourceBundleBasedTranslator : ArgumentsSupportingTranslator

Represents an ITranslator which reuses ResourceBundle properties based capabilities but uses an enhanced fallback mechanism. Instead of falling back to Locale.getDefault one is able to specify fallback Locale oneself. Whether this includes Locale.getDefault or not is up to the user.

Translator

class Translator : ArgumentsSupportingTranslator

Represents an ITranslator which uses an ITranslationSupplier to retrieve translations and LocaleOrderDecider to determine in which order it should try to find translations for a given ITranslatable.

UsingDefaultTranslator

class UsingDefaultTranslator : ArgumentsSupportingTranslator

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