TolgeeAndroid

A specialized implementation of the Tolgee class for Android that provides methods for retrieving and formatting translations associated with string resources within an Android application. The class uses Kotlin Flows and instant methods for localized text retrieval and dynamic text formatting based on string resources.

Parameters

config

The configuration object providing settings for Tolgee.

Types

Link copied to clipboard
object Companion

A companion object for utility functions related to string resources and key retrieval.

Properties

Link copied to clipboard
val changeFlow: <Error class: unknown class>

A flow that emits whenever translations change.

Link copied to clipboard
open override val config: Tolgee.Config

Functions

Link copied to clipboard

Registers a listener to be notified when translations change.

Link copied to clipboard
open fun getLocale(): <Error class: unknown class>

Gets the current locale for the Tolgee instance.

Link copied to clipboard
open suspend fun preload()
fun preload(lifecycleOwner: LifecycleOwner): Job

Preloads the required languages and their translations for the current Tolgee instance.

Link copied to clipboard

Unregisters a previously registered change listener.

Link copied to clipboard
open fun setLocale(locale: <Error class: unknown class>): <Error class: unknown class>

Sets the current locale for the Tolgee instance, updating it in the reactive locale flow.

open fun setLocale(localeTag: String): <Error class: unknown class>

Adjusts the current locale used for translations.

Link copied to clipboard
open fun t(key: String, parameters: TolgeeMessageParams = TolgeeMessageParams.None): String?

Immediate Tolgee translation for a key with parameters.

fun t(context: Context, @StringRes id: Int): String

Provides an immediate translation for the given string resource ID within the given context. If a translation key is derived from the string resource, it retrieves the translation using Tolgee. Otherwise, it falls back to returning the default string resource value.

fun t(context: Context, @StringRes id: Int, vararg formatArgs: Any): String

Provides an immediate translation for a given string resource ID with optional format arguments. If the translation key is found in the string resource, it retrieves the translation; otherwise, the default string resource value is returned.

Link copied to clipboard
open fun tArray(key: String): List<String>
fun tArray(resources: Resources, @ArrayRes id: Int): List<String>
Link copied to clipboard
open fun tArrayFlow(key: String): Flow<List<String>>
fun tArrayFlow(resources: Resources, @ArrayRes id: Int): Flow<List<String>>
Link copied to clipboard
open fun tFlow(key: String, parameters: TolgeeMessageParams = TolgeeMessageParams.None): Flow<String>

Updating Tolgee translation for a key with parameters.

fun tFlow(context: Context, @StringRes id: Int): Flow<String>

Retrieves a translation for the given string resource ID and emits the localized text as a Flow.

fun tFlow(context: Context, @StringRes id: Int, vararg formatArgs: Any): Flow<String>

Provides a flow of translated strings for a given string resource ID with optional formatting arguments. The method first emits the string resolved from the context's resources. If the key corresponding to the string resource ID exists, it emits translations for the key using the provided formatting arguments.

Link copied to clipboard
fun tPlural(resources: Resources, @PluralsRes id: Int, quantity: Int): String
fun tPlural(resources: Resources, @PluralsRes id: Int, quantity: Int, vararg formatArgs: Any): String
Link copied to clipboard
fun tPluralFlow(resources: Resources, @PluralsRes id: Int, quantity: Int): Flow<String>
fun tPluralFlow(resources: Resources, @PluralsRes id: Int, quantity: Int, vararg formatArgs: Any): Flow<String>
Link copied to clipboard
fun tStyled(context: Context, @StringRes id: Int): CharSequence

Provides an immediate translation for the given string resource ID within the given context. If a translation key is derived from the string resource, it retrieves the translation using Tolgee. Otherwise, it falls back to returning the default string resource value.