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

PropertiesBasedTranslationSupplier

abstract class PropertiesBasedTranslationSupplier<in T> : TranslationSupplier (source)

A base class for properties based TranslationSuppliers which provides a loading and caching mechanism of properties files.

There is no way to purge the cache. This class is intended for a one run process where translations do not change in between.

It is compatible with Java's Properties - thus properties files should also use ISO-8859-1 as encoding.

Parameters

T - Translations are grouped by a certain aspect (for instance, by Locale). T defines the type of it.

Constructors

<init>

PropertiesBasedTranslationSupplier()

A base class for properties based TranslationSuppliers which provides a loading and caching mechanism of properties files.

Functions

getFileNameFor

fun getFileNameFor(baseName: String, locale: Locale): String

Returns the name of the properties file without extension -- including the package (as prefixed relative path) in which it resides if necessary -- in which we expect to find a translation in the given locale for baseName.

getOrLoadProperties

fun getOrLoadProperties(key: T, fileName: String, keyCreator: (String) -> String): Map<String, String>

Gets the cached Properties content as Map for the given key or loads the properties file with the given fileName and creates a map out of it using the given keyCreator function to create the keys of the map, based on a key of a property.

Inherited Functions

get

abstract fun get(translatable: Translatable, locale: Locale): String?

Returns the translation for the given translatable and the given locale or null if it does not have any translation.

Inheritors

PropertiesPerEntityAndLocaleTranslationSupplier

class PropertiesPerEntityAndLocaleTranslationSupplier : PropertiesBasedTranslationSupplier<String>

Represents a TranslationSupplier which is based on properties-files which are structured per entity (enum, object or class) and Locale.

PropertiesPerLocaleTranslationSupplier

class PropertiesPerLocaleTranslationSupplier : PropertiesBasedTranslationSupplier<Locale>

Represents a TranslationSupplier which is based on properties-files which are structured per Locale.