addLocalizations

fun addLocalizations(bundleName: String, locales: List<DiscordLocale>)(source)
fun addLocalizations(bundleName: String, vararg locales: DiscordLocale)(source)

Adds the specified bundle names with its locales; those bundles will be used for command localization (name, description, options, choices...).

All the locales will be considered as pointing to a valid localization bundle, logging a warning if it can't be found.

Localization keys

The keys are the same as those generated by LocalizationFunction.

Localization file

The file can be anywhere and of any extension, as long as it can be read by a LocalizationMapReader, see the default implementation.

To know the final name of your file, which in most cases is <name>_<language>_<country>.<extension>, you can take a look at the language tag of your DiscordLocale, replacing the - (hyphen) by a _ (underscore).

For example, MyCommands ->[DiscordLocale.GERMAN, DiscordLocale.FRENCH, DiscordLocale.SPANISH] will, by default, read in the /bc_localization (configurable) folder:

  • DiscordLocale.GERMAN ->de ->MyCommands_de.json

  • DiscordLocale.FRENCH ->fr ->MyCommands_fr.json

  • DiscordLocale.SPANISH ->es-ES ->es_ES ->MyCommand_es_ES.json

See DefaultLocalizationMapProvider and DefaultJsonLocalizationMapReader for default implementation details.

Spring property

The property botcommands.application.localizations is suffixed with the bundle name to the key, and the value is an array of DiscordLocale, for example, botcommands.application.localizations.MyBundle=english_us,german,french.

Parameters

bundleName

The name of the localization bundle

locales

The locales the localization bundle supports

See also