LocalizationContext

Interface helping in localizing content, supports preset localization bundles, localization prefixes, and context-aware localization.

While this interface cannot be injected, sub-interfaces can.

See also

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The locale used when no locale is specified, the best locale is picked in this order:

Link copied to clipboard

Returns the localization bundle of the current context.

Link copied to clipboard
abstract val localizationPrefix: String?

Returns the localization prefix of the current context.

Functions

Link copied to clipboard
open fun localize(localizationPath: String, vararg entries: Localization.Entry): String

Localizes the provided path, with the best locale available.

abstract fun localize(locale: DiscordLocale, localizationPath: String, vararg entries: Localization.Entry): String

Localizes the provided path, with the provided locale.

Link copied to clipboard
fun LocalizationContext.localize(localizationPath: String, vararg entries: PairEntry): String

Localizes the provided path, with the best locale available.

fun LocalizationContext.localize(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry): String

Localizes the provided path, with the provided locale.

Link copied to clipboard
open fun localizeOrNull(localizationPath: String, vararg entries: Localization.Entry): String?

Localizes the provided path, with the best locale available, or returns null if the path does not exist.

abstract fun localizeOrNull(locale: DiscordLocale, localizationPath: String, vararg entries: Localization.Entry): String?

Localizes the provided path, with the provided locale, or returns null if the path does not exist.

Link copied to clipboard
fun LocalizationContext.localizeOrNull(localizationPath: String, vararg entries: PairEntry): String?

Localizes the provided path, with the best locale available, or returns null if the path does not exist.

fun LocalizationContext.localizeOrNull(locale: DiscordLocale, localizationPath: String, vararg entries: PairEntry): String?

Localizes the provided path, with the provided locale, or returns null if the path does not exist.

Link copied to clipboard
@CheckReturnValue
abstract fun switchBundle(localizationBundle: String): LocalizationContext

Returns a new localization context with the specified localization bundle, and resets the localization prefix.

Link copied to clipboard
@CheckReturnValue
abstract fun withBundle(localizationBundle: String): LocalizationContext

Returns a new localization context with the specified localization bundle.

Link copied to clipboard
@CheckReturnValue
abstract fun withGuildLocale(guildLocale: DiscordLocale?): TextLocalizationContext

Returns a new TextLocalizationContext with the specified guild locale.

Link copied to clipboard
@CheckReturnValue
abstract fun withPrefix(localizationPrefix: String?): LocalizationContext

Returns a new localization context with the specified localization prefix.

Link copied to clipboard
@CheckReturnValue
abstract fun withUserLocale(userLocale: DiscordLocale?): AppLocalizationContext

Returns a new AppLocalizationContext with the specified user locale.