Next.js Discord

Discord Forum

How to integrate i18next in next 12?

Unanswered
Common carp posted this in #help-forum
Open in Discord
Original message was deleted.

12 Replies

Common carp
This is my locale files. When I call t("1language") it render 1language instead of Language
{
  "1language": "Language",
  "select": "Select"
}
I have a very important question... why are you using next 12? Lol
Its going to be really hard to find help when using next12
I would say it's not related to the next.js version
@Common carp This is my locale files. When I call `t("1language")` it render `1language` instead of `Language` ts { "1language": "Language", "select": "Select" }
that happens when i18 didn't find a match for key 1language, then I remember they throw the key itself
something is wrong with i18
Common carp
I find the error. I should put getStaticProps in index.page.tsx instead of /language/index.tsx
export const getStaticProps = async ({ locale }: { locale: string }) => {
  return {
    props: {
      locale,
      ...(await serverSideTranslations(locale, ["language"])),
    },
  };
};
show me this serverSideTranslations
Common carp
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
The problem is solved. Thanks
Good, what was the issue?
Common carp
If I was correct, I put getStaticProps in /pages/account/_components/language/index.tsx so the locale files are not downloaded so I call t("1language") it can not find the key. I should put it getStaticProps in /pages/account/index.page.tsx