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

Did you find this page helpful?