Internationalisation (i18n)
The i18n { } builder allows you to configure how your bot handles translations and retrieves locales for
internationalisation and localisation.
Kord Extensions provides built-in translations for several locales, listed in the SupportedLocales object.
You can contribute your own translations (or check in on our progress)
on Weblate.
ExtensibleBot(TOKEN) {
// ...
i18n {
defaultLocale = SupportedLocales.SPANISH
applicationCommandLocale(SupportedLocales.ALL_LOCALES_SET)
interactionUserLocaleResolver()
interactionGuildLocaleResolver()
}
}
Builders
Register a custom locale resolver.
Locale resolvers return a Locale or null based on the parameters passed in, defining which locale should be
used for translations in that context.
This also allows you to write configuration commands so users can pick their preferred locale, if you wish.
You can register multiple locale resolvers, and they'll be tried (in registration order) until one of them
returns something other than null.
For more information, see [[the i18n documentation]].
A [[Behavior]] representing the current guild, if any.
A [[Behavior]] representing the current channel, if any.
A [[Behavior]] representing the current user, if any.
A [[Behavior]] representing the current interaction, if any.
Register a callback that constructs and returns an alternative implementation of the TranslationsProvider
type, if needed.
A callable object that returns the configured default locale.
Functions
Registers the given locales as application command locales. Your bot uses these locales to translate application commands when they're registered with Discord.
Supply SupportedLocales.ALL_LOCALES_SET to support all locales that Kord Extensions provides translations for.
Locales you want your bot to support.
Registers a default locale resolver which attempts to resolve locales using the language set in the current guild's server settings.
Registers a default locale resolver which attempts to resolve locales using the current user's Discord language setting.
Properties
Your bot's default locale.
This is the locale used as the default locale when registering application commands, and when the locale resolvers don't return one.