i18n applyLocalizedBuilder

Hello, i have some problems with i18n. I am currently trying to localize slash commands, but i can't get it to work. My code is:
registry.registerChatInputCommand((builder) =>
applyLocalizedBuilder(builder, LanguageKey.Name, LanguageKey.Description) //
.setIntegrationTypes(integrationTypes)
.setContexts(contexts)
.addUserOption((option) =>
applyLocalizedBuilder(
option,
"commands/level:userOptionName",
"commands/level:userOptionDescription",
) //
.setRequired(false),
),
);
registry.registerChatInputCommand((builder) =>
applyLocalizedBuilder(builder, LanguageKey.Name, LanguageKey.Description) //
.setIntegrationTypes(integrationTypes)
.setContexts(contexts)
.addUserOption((option) =>
applyLocalizedBuilder(
option,
"commands/level:userOptionName",
"commands/level:userOptionDescription",
) //
.setRequired(false),
),
);
And then i have src/languages/de/commands/level.json and src/languages/en-US/commands/level.json In the en-US folder for example:
{
"name": "level",
"description": "Displays the level and experience points (XP).",
"userOptionName": "username",
"userOptionDescription": "The user whose level and XP should be displayed.",
"noXP": "You don't have any XP yet!",
"status": "You are level {{level}} with {{current}}/{{needed}} XP."
}
{
"name": "level",
"description": "Displays the level and experience points (XP).",
"userOptionName": "username",
"userOptionDescription": "The user whose level and XP should be displayed.",
"noXP": "You don't have any XP yet!",
"status": "You are level {{level}} with {{current}}/{{needed}} XP."
}
But as you can see it throws an error and i don't get why. I would appreciate some help 😅
No description
2 Replies
Favna
Favna•3w ago
Seems like you didn't init the plugin correctly. What are your client options like and do you have import '@sapphire/plugin-i18next/register'; anywhere?
Julian
JulianOP•3w ago
I think the problem was having nonExplicitSupportedLngs: true, in the config, after removing that it worked

Did you find this page helpful?