i18n not giving correct strings

In src/languages/en-US/coreCommands/ping.json I have this:
{
"loading": "Calculating the latencies..."
}
{
"loading": "Calculating the latencies..."
}
I try to use it in the ping command:
const t = await fetchT(interaction);
console.log(await resolveKey("coreCommands/ping:loading"));
console.log(t("coreCommands/ping:loading"));
const t = await fetchT(interaction);
console.log(await resolveKey("coreCommands/ping:loading"));
console.log(t("coreCommands/ping:loading"));
resolveKey gives me an empty string and using t() function just gives me the text "loading". What's happening here?
No description
Solution:
the issue was while building. Apparently esbuild converts .json to .js
Jump to solution
15 Replies
mallusrgreat
mallusrgreatOP7mo ago
I've checked with fetchLanguage(interaction) that the language code is en-US.
čamdžić
čamdžić7mo ago
I don’t see anything wrong Did you registered plugin? Did you changed i18n in client options? Can you try resolveKey(interaction, “key”)
čamdžić
čamdžić7mo ago
No description
mallusrgreat
mallusrgreatOP7mo ago
only changed fetchLanguage yeah
čamdžić
čamdžić7mo ago
What about this
mallusrgreat
mallusrgreatOP7mo ago
literally putting it "key"?
čamdžić
čamdžić7mo ago
No coreCommands/ping:loading
mallusrgreat
mallusrgreatOP7mo ago
still gives me empty string
čamdžić
čamdžić7mo ago
That’s weird Can I see fetchLanguage
Tejas
Tejas7mo ago
fetchLanguage(ctx) {
return ctx.interactionGuildLocale || ctx.interactionLocale || "en-US";
}
fetchLanguage(ctx) {
return ctx.interactionGuildLocale || ctx.interactionLocale || "en-US";
}
čamdžić
čamdžić7mo ago
Hmm that is really weird Everything looks right You’re trying to use it in a command?
Tejas
Tejas7mo ago
correct
čamdžić
čamdžić7mo ago
I have no idea. I18n is configured like that on Skyra Bot too You can try waiting for maintainers
Solution
mallusrgreat
mallusrgreat7mo ago
the issue was while building. Apparently esbuild converts .json to .js
čamdžić
čamdžić7mo ago
Oh alright

Did you find this page helpful?