Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the language the label does not update #2253

Open
matteo-gobbo opened this issue Jan 18, 2024 · 4 comments
Open

Changing the language the label does not update #2253

matteo-gobbo opened this issue Jan 18, 2024 · 4 comments
Labels

Comments

@matteo-gobbo
Copy link

馃悰 Bug Report

Hi, when I change la language using link at the first render the label doesn't update.

To Reproduce

A codesandbox example
To reproduce:

  • Go to /demo
  • Click on EN
  • You will see at first render the old label

Expected behavior

When changing the path I expect that the label is updated too.

Your Environment

  • runtime: node v18.17.0
  • i18next: ^23.7.16
  • next-i18next: ^15.0.0
  • react-i18next: ^13.5.0
  • os: Mac
@adrai
Copy link
Member

adrai commented Jan 18, 2024

That's probably because you set the locale to 'it' here:

export const getStaticProps: GetStaticProps = async () => {
    const locale = "it";

    return {
        props: {
            locale,
            ...(await serverSideTranslations(locale, ["common"])),
        },
    };
};

do this instead:

export const getStaticProps: GetStaticProps<Props> = async ({
  locale,
}) => ({
  props: {
    locale,
    ...(await serverSideTranslations(locale ?? 'it', [
      'common'
    ])),
  },
})

Why do you have an "en" folder?
Please compare with this example: https://github.com/i18next/next-i18next/tree/master/examples/simple
Or if you use ssg with this one: https://github.com/i18next/next-i18next/tree/master/examples/ssg

@matteo-gobbo
Copy link
Author

Thank you @adrai for your reply.

Sadly this is only a replica of a bigger project that is structured this way with all italian pages on one side and all english pages under the folder en. So this is way you see locale hardcoded to "it" or "en".

@alfredosalzillo
Copy link

I'm experiencing the same problem, using the 14.* version solve the issue.

@matteo-gobbo
Copy link
Author

Yes @alfredosalzillo we're actually using the v14 and it works fine. While trying to upgrade to v15 I found that problem.

@adrai adrai added the stale label Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants