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
mallusrgreatOP9mo ago
I've checked with fetchLanguage(interaction) that the language code is en-US.
čamdžić
čamdžić9mo 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ć9mo ago
No description
mallusrgreat
mallusrgreatOP9mo ago
only changed fetchLanguage yeah
čamdžić
čamdžić9mo ago
What about this
mallusrgreat
mallusrgreatOP9mo ago
literally putting it "key"?
čamdžić
čamdžić9mo ago
No coreCommands/ping:loading
mallusrgreat
mallusrgreatOP9mo ago
still gives me empty string
čamdžić
čamdžić9mo ago
That’s weird Can I see fetchLanguage
Tejas
Tejas9mo ago
fetchLanguage(ctx) {
return ctx.interactionGuildLocale || ctx.interactionLocale || "en-US";
}
fetchLanguage(ctx) {
return ctx.interactionGuildLocale || ctx.interactionLocale || "en-US";
}
čamdžić
čamdžić9mo ago
Hmm that is really weird Everything looks right You’re trying to use it in a command?
Tejas
Tejas9mo ago
correct
čamdžić
čamdžić9mo ago
I have no idea. I18n is configured like that on Skyra Bot too You can try waiting for maintainers
Solution
mallusrgreat
mallusrgreat9mo ago
the issue was while building. Apparently esbuild converts .json to .js
čamdžić
čamdžić9mo ago
Oh alright

Did you find this page helpful?