stringResource

Retrieves a localized string resource based on the provided resource ID using Tolgee for translations. If a translation is available from Tolgee, it is used; otherwise, the default string resource is returned.

Return

The translated or default string resource as a String.

Parameters

tolgee

An instance of the Tolgee translation library for managing translations.

id

The resource ID of the string to be translated or retrieved.


Returns a localized string from the given resource ID.

This function is a wrapper around the stringResource that integrates with the Tolgee instance for localization. If Tolgee is not initialized, it falls back to the standard Compose stringResource.

Return

The localized string associated with the provided resource ID.

Parameters

id

The resource ID of the string to retrieve.


fun stringResource(tolgee: Tolgee, @StringRes id: Int, vararg formatArgs: Any): String(source)

Retrieves a string resource based on the given parameters, supporting dynamic translation with Tolgee integration.

Return

The translated or resource string corresponding to the specified resource ID.

Parameters

tolgee

The Tolgee instance used for translations.

id

The resource ID of the string to be retrieved.

formatArgs

Optional format arguments to replace placeholders in the string.


fun stringResource(@StringRes id: Int, vararg formatArgs: Any): String(source)

Retrieves a localized string resource. If a Tolgee instance is available, it uses it to fetch the translated string; otherwise, falls back to the default Compose string resource.

Return

The localized string based on the provided resource ID and arguments.

Parameters

id

The resource ID of the string.

formatArgs

The arguments to be used for formatting the string resource.

fun stringResource(tolgee: <Error class: unknown class>, key: String, default: String?, table: String? = null): String(source)

Provides a localized string based on the given key and optional default, using the specified Tolgee instance.

Return

The localized string corresponding to the provided key, or a fallback based on the default and table parameters.

Parameters

tolgee

An instance of the Tolgee library used for retrieving translations.

key

The key used to look up the localized string.

default

The default string returned if no translation is found. Can be null.

table

An optional parameter specifying the translation table or namespace. Defaults to null.


fun stringResource(key: String, default: String?, table: String? = null): String(source)

Retrieves a localized string based on the provided key, default value, and optional table name.

If a localization instance is available, it fetches the translation using it. Otherwise, it attempts to fetch the localized string from the application bundle or returns the default string.

Return

The localized string if available, or the fallback string based on the provided default or key.

Parameters

key

The key used to identify the localized string.

default

The default string to use if no localized string is found. If blank, it will be treated as null.

table

The optional table or namespace for looking up the key. Defaults to null if not specified.


fun stringResource(tolgee: <Error class: unknown class>, key: String, default: String?, table: String? = null, vararg args: Any): String(source)

Retrieves a localized string resource using the provided translation key, default value, optional table, and optional arguments. The translation is fetched from the specified Tolgee instance and updates dynamically using a state-based approach.

Return

A string value representing the localized and formatted resource.

Parameters

tolgee

The Tolgee instance responsible for fetching translations.

key

The translation key used to identify the desired string resource.

default

The default string to use if no translation is found.

table

The optional table name where the key is located.

args

Optional arguments for formatting the translated string.


fun stringResource(key: String, default: String?, table: String? = null, vararg args: Any): String(source)

Retrieves a localized and formatted string based on the specified key, default value, table, and arguments. The method ensures the use of a Tolgee instance if available, otherwise falls back to bundle-based localization.

Return

The localized and formatted string; returns an empty string if no localization is found and no default value is provided.

Parameters

key

The key identifying the localized string resource.

default

The default string to use if no localization is found. Can be null.

table

The optional table from which the localization data is fetched. Can be null.

args

The arguments to format the localized string.

fun stringResource(tolgee: Tolgee, resource: StringResource): String(source)

Retrieves a localized string resource using the provided Tolgee translation library and resource key.

Return

The localized string corresponding to the provided key.

Parameters

tolgee

The Tolgee instance used for fetching translations.

resource

The StringResource containing the key for the desired translation.


fun stringResource(resource: StringResource): String(source)

Returns a localized string for the given string resource.

This function checks if an instance of Tolgee exists. If it does, it retrieves the string translation using Tolgee. Otherwise, it falls back to the default string resource resolution.

Return

The localized string corresponding to the given resource.

Parameters

resource

The string resource to be localized.


fun stringResource(tolgee: Tolgee, resource: StringResource, vararg formatArgs: Any): String(source)

Composable function to retrieve a localized string resource using Tolgee.

Return

The localized string resource.

Parameters

tolgee

An instance of Tolgee used for fetching translations.

resource

The resource key representing the string to be translated.

formatArgs

Optional arguments to format the translated string.


fun stringResource(resource: StringResource, vararg formatArgs: Any): String(source)

Provides a localized string for the given resource and format arguments.

This function first attempts to use the Tolgee instance for retrieving the localized string. If Tolgee is not initialized, it falls back to the Compose resource string method.

Return

The localized string formatted with the provided arguments.

Parameters

resource

The string resource containing the key for localization.

formatArgs

Optional arguments to format the localized string.