i18n support is not compatible with next export #18957
Replies: 7 comments 13 replies
-
See answer in #18318 (comment) |
Beta Was this translation helpful? Give feedback.
-
Faced the same situation today. A major setback in the release dates. I wish I wasn't given this idea that nextjs gives complete static support. That single note in i18n documentation section should be in the main introduction of the repo. So new users can make judgment before hand. |
Beta Was this translation helpful? Give feedback.
-
Got the same problem earlier this year, made me quit my project for weeks. Should have used Nuxt.js to build the page, honestly. Can't understand why you shouldn't allow to use next export with i18n by design... |
Beta Was this translation helpful? Give feedback.
-
This problem also occurs when I deploy on fleek. Have any friends met this problem and solved it |
Beta Was this translation helpful? Give feedback.
-
I ended up dropping Next.js and switching to Gatsby for this specific reason. I think integrated support would be a lot more reasonable than trying to find hacky workarounds |
Beta Was this translation helpful? Give feedback.
-
Hello I show you my soluce with only i18n-js // i18n.ts
import i18n from "i18n-js";
import en from "./en.json";
import fr from "./fr.json";
const localeEnable = ["fr", "en"];
const formatLocale = () => {
const { language } = window.navigator;
if (language.includes("en")) return "en";
if (language.includes("fr")) return "fr";
if (!localeEnable.includes(language)) return "en";
return "en";
};
// Set the key-value pairs for the different languages you want to support.
i18n.translations = {
en,
fr,
};
// Set the locale once at the beginning of your app.
i18n.locale = "en";
const useTranslate = () => {
return (t: string) => {
if (typeof window !== "undefined") {
i18n.locale = formatLocale();
}
return i18n.t(t);
};
};
export default useTranslate;
// home.tsx
import useTranslate from "../locales/i18n";
const t = useTranslate();
return (<p>{t("idstring")}</p>) |
Beta Was this translation helpful? Give feedback.
-
A while ago I created something like this to solve this problem: https://github.com/cyntler/next-locales. |
Beta Was this translation helpful? Give feedback.
-
I just spent a couple of days upgrading a SSG website to Next.js 10 to take advantage of the new built-in i18n feature. All works great during local development. When I come to build and then export it, I get the following error:
I'm a little confused by this. There's nothing about this in the docs for internationalised routing or static HTML export.
The i18n features (like current locale) are available in the context parameter of
getStaticProps
andgetStaticPaths
. I can't understand why that would be the case if SSG is not supported by this feature.Is anyone able to help shed any light on this?
Beta Was this translation helpful? Give feedback.
All reactions