Next.js Discord

Discord Forum

getTranslations returning wrong messages

Answered
Japanese flying squid posted this in #help-forum
Open in Discord
Japanese flying squidOP
I am using getTranslations in API route and it's always giving english ( default ) messages.
Answered by Japanese flying squid
const locale = request.cookies.get("NEXT_LOCALE")?.value || "en";
const t = await getTranslations({ locale, namespace: "Messages" });


SOLVED
View full answer

3 Replies

Japanese flying squidOP
So basically, I have two languages. When the user sends request from english version (en locale, I am using also i18 routing) it gives english messages. But when sending from different language with different locale, getTranslation still gives me english messages in the POST request handler
Japanese flying squidOP
Japanese flying squidOP
const locale = request.cookies.get("NEXT_LOCALE")?.value || "en";
const t = await getTranslations({ locale, namespace: "Messages" });


SOLVED
Answer