I’m developing a Discord bot with the nextcord library and need assistance in localizing the names of slash commands. Currently, I can modify the command content using ctx.locale, but I’m looking to have the command name display differently depending on the user’s language setting in Discord.
For instance:
- Users who speak Korean should see:
/정보
- English-speaking users should see:
/info
I’ve successfully adjusted the command descriptions and response content, but the command names remain the same for everyone. I know other bots can do this, so it should be possible.
Can nextcord offer a way to set different command names based on locale? I’ve been searching for guidance in the documentation but can’t find a straightforward answer to this issue.
You can use the name_localizations parameter that’s already built into nextcord. Just pass a dictionary with locale codes and their translations when registering your slash command. For your example: name_localizations={'ko': '정보', 'en-US': 'info', 'en-GB': 'info'} in your decorator or registration function. Discord automatically shows the right localized name based on each user’s language settings. You’ll need a recent version of nextcord since this was added later, and don’t forget to sync your commands after making changes.
Yeah, name_localizations is the way to go, but I hit some snags when I first tried it. You need nextcord 2.0.0+ since older versions are buggy with this feature. After adding localizations, force sync your commands again - Discord won’t pick up the changes otherwise. I had to delete and re-add my bot from test servers multiple times before it stuck. Watch out for locale codes - ‘ko’ worked way better than ‘ko-KR’ for Korean in my tests. The localized names only show up if users actually have their Discord language set to match, so don’t just assume it’s working. Test it by switching your Discord language settings.
you can use the name_localizations param in nextcord to handle different command names. just create a dict with locale codes like {'ko': '정보', 'en-US': 'info'} when defining the slash command. also, don’t forget to check your bot’s intents!