2

How can I make pages like /en , /th/ for build created by next build && next export if i18n you can't use in next.config.js , also , you can't use dynamic routing [lang].js ?

alanionita
  • 1,272
  • 1
  • 16
  • 34
Andrey Radkevich
  • 3,012
  • 5
  • 25
  • 57
  • 1
    Does this answer your question? [i18n support is not compatible with next export. (SSR - NextJS 10)](https://stackoverflow.com/questions/65513435/i18n-support-is-not-compatible-with-next-export-ssr-nextjs-10) – Danila Aug 01 '21 at 10:52
  • It doesn't give me an answer to my question, ok I can't use it, but how can I implement lang support with next export – Andrey Radkevich Aug 01 '21 at 12:57
  • 1
    Manually, with dynamic routes, `[lang].js` and etc – Danila Aug 01 '21 at 13:37

2 Answers2

1

Internationalisation feature now supports static exports

Official docs: https://nextjs.org/docs/app/building-your-application/routing/internationalization#static-generation

Sample code (from docs)

# app/[lang]/layout.js

export async function generateStaticParams() {
  return [{ lang: 'en-US' }, { lang: 'de' }]
}
 
export default function Root({ children, params }) {
  return (
    <html lang={params.lang}>
      <body>{children}</body>
    </html>
  )
}
alanionita
  • 1,272
  • 1
  • 16
  • 34
  • Hey, do you know whether this will still work with `output: export`? Or is this limited to static rendering but with NextJS as server backend? – Felixkruemel Jul 20 '23 at 19:45
  • It should because it looks like NextJS will produce the pages at export with html lang={params.lang}. Depending on how many languages you have you should have the same about of html assets/ – alanionita Jul 21 '23 at 07:14
0

Internationalisation features are not supported by NextJS static builds

Official NextJS mention of this https://nextjs.org/docs/advanced-features/static-html-export

Unsupported Features Features that require a Node.js server, or dynamic logic that cannot be computed during the build process, are not supported:

  • Internationalized Routing
  • ...
alanionita
  • 1,272
  • 1
  • 16
  • 34