Localization

JDA uses the LocalizationFunction for localizing slash commands. We implement this interface based on MessageResolver (see the localization wiki for details). If you want to disable command localization just call JDACBuilder#localizeCommands(false).

The bundle used is generally default. If the interaction controller class or the package-info.java in the same package as the class is annotated by @Bundle, the specified bundle will be used instead. If the localization key isn't found in this bundle, the default bundle will be searched as a fallback option.

Example

main/Greet.java
@Bundle("greet")
@Interaction
public class Greet {

    @Command("greet user")
    public void onCommand(CommandEvent event, Member member) { 
        event.reply("Hello World %s!".formatted(member.getAsMention()));
    }    
}
resources/greet_en.ftl
greet-user-description=Greets a user
greet-user-options-member-name=user
greet-user-options-member-description=The user to greet
resources/greet_de.ftl
greet-name=grüße
greet-user-name=nutzer
greet-user-description=Begrüßt einen Nutzer
greet-user-options-member-name=nutzer
greet-user-options-member-description=Der Nutzer der gegrüßt werden soll

See the JDA Docs for more details about the localization keys and locales. (We use DiscordLocale#toLocale() to convert the locales).