#i18n applyLocalizedBuilder

1 messages · Page 1 of 1 (latest)

nimble light
#

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),
    ),
);

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."
}

But as you can see it throws an error and i don't get why. I would appreciate some help 😅

gloomy hollowBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

radiant zinc
#

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?