ResourceBundleTranslations

open class ResourceBundleTranslations(val defaultLocaleBuilder: () -> Locale) : TranslationsProvider

Translation provider backed by Java's ResourceBundles. This makes use of .properties files that are standard across the Java ecosystem.

Bundles are resolved as follows:

  • If bundleName is null, default to kordex

  • Prefix the bundle name with translations.

  • If bundleName doesn't contain a . character, suffix it with .strings

With a bundleName of null, this means the bundle will be named translations.kordex.strings, which will resolve to translations/kordex/strings${_locale ?: ""}.properties in the resources.

Constructors

Link copied to clipboard
constructor(defaultLocaleBuilder: () -> Locale)

Properties

Link copied to clipboard

Default locale, resolved via defaultLocaleBuilder. Avoid accessing this outside of your get functions, as accessing it too early will prevent the user from configuring it properly.

Link copied to clipboard

Functions

Link copied to clipboard
open override fun get(key: Key): String

Get a translation by key.

Link copied to clipboard
open override fun getKoin(): Koin

Get the associated Koin instance.

Link copied to clipboard
open override fun hasKey(key: Key): Boolean

Check whether a translation key exists.

Link copied to clipboard
open override fun translate(key: Key, replacements: Array<Any?>): String

Get a formatted translation using the provided arguments.

Link copied to clipboard
open override fun translateNamed(key: Key, replacements: Map<String, Any?>): String

Get a formatted translation using the provided arguments.