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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations are not loading during client-side navigation #558

Closed
vaniyokk opened this issue Mar 31, 2021 · 2 comments
Closed

Translations are not loading during client-side navigation #558

vaniyokk opened this issue Mar 31, 2021 · 2 comments

Comments

@vaniyokk
Copy link

vaniyokk commented Mar 31, 2021

Hi! Unfortunately translations are not loading during client-side navigation in latest version.

I have latest Next.js v10.1.0 and next-translate v1.0.5

My page is wrapped in a HOC that adding page metadata and not using any data-fetching methods.

import { NextPage } from "next";

import Discover from "~/components/Discover";
import withStandardMetadata from "~/components/providers/withStandardMetadata";

const DiscoverPage: NextPage = (): JSX.Element => <Discover />;

export default withStandardMetadata({
  titleKey: "discover_title",
  descriptionKey: "discover_description",
  keywordsKey: "discover_keywords"
})(DiscoverPage);

If I downgrade next-translate to 1.0.1 translations are loading fine on both server-side and client-side navigation.
I checked every version prior to 1.0.5 and all versions have same problem.

adding of empty getStaticProps to my page like this

export const getStaticProps: GetStaticProps<
  Record<string, unknown>
> = async () => ({ props: {} });

fixes the problem but I don't want to bloat all my pages with such dummy code.

Is there any other way to get around with this?
It looks like a regression from v1.0.1. Do you more information to investigate the problem?

@picardplaisimond
Copy link

picardplaisimond commented Apr 2, 2021

Someone have a solution for this ? This is a new problem for me too.
I'm just using a normal HOC without any extra fetching.
I think it's a false alert from "next-translate". I'm also getting:

🚨 [next-translate] In Next 10.x.x there is an issue related to i18n and getInitialProps. We recommend to replace getInitialProps to getServerSideProps on /index.js. Issue: https://github.com/vercel/next.js/issues/18396

For now, I chose to dowgrade to v1.0.1.

@aralroca
Copy link
Owner

aralroca commented Apr 6, 2021

@picardplaisimond this issue will be fixed after this PR will be merged: vercel/next.js#21930

@vaniyokk using HOC is using getInitialProps as default to avoid conflicts with HOC, and getInitialProps has this issue that will be fixed after this PR merged vercel/next.js#21930. However, to force to load the translations in a different loader you should define another loader (as you comment, and empty getStaticProps solves). For now is the only way.

I am closing the issue as it is a duplicate of this one: #453

@aralroca aralroca closed this as completed Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants