i18n and static export
See original GitHub issueDescribe the feature you’d like to request
There is certain set of cases when nothing stops static export from working with i18n, for example using path-based approach is trivial: /en/...
or /fr/...
There was an issue #37575 here but it got stalled. I would like to once again support rationale for this request:
- SSG is often used to deploy to public S3 storage
- When using in combination CDN there is virtually no other way to cache the language specific variants besides explicit path
- If developer still wants to use domain-first approach, we can also generate static exports in paths like
out/example.fr/...
,out/example.nl/...
. Then there is gonna be a bit manual but available option to specify corresponding CNAME for each domain on the side of the DNS\CDN
Describe the solution you’d like
Interestingly when I tried removing this condition: https://github.com/vercel/next.js/blob/8b721227cf82a0af3be07663dc8d218430c80514/packages/next/export/index.ts#L332 it just worked exactly as needed for path-based approach: generating correct folders and subpaths. Maybe we should replace the condition with check if the locale is configured to use domain?
Describe alternatives you’ve considered
Honestly initially I was considering switching to another library, but now I’m just using this hack described above
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:5
Top Results From Across the Web
Static HTML Export with i18n compatibility in Next.js
1. Remove the i18n options from next. · 2. Create a [locale] folder inside your pages directory. · 3. Create a getStatic. ·...
Read more >Static HTML Export with i18n compatibility in Next.js - locize
1. Remove the i18n options from next. · 2. Create a [locale] folder inside your pages directory. · 3. Create a getStatic. ·...
Read more >i18n routes in Static Sites using NextJS - Medium
NextJS is a robust solution for serving static sites by using its export command. But it doesn't support the i18n plugin, unless you...
Read more >next-export-i18n - npm
Internationalize next.js with true support for next export. Latest version: 2.1.0, last published: 3 months ago.
Read more >next.js: i18n with static sites - stackcodify
Next.js provides a true out-of-the-box static sites generator. The next export command generates a set of fully optimized static HTML files.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@esseswann I use next-i18next to exported project ! from a blog but I forget link ~
@esseswann I tried your approach but it didnt work
I have a second page beside
index.js
that hasgetStaticProps
and it fails at this point:next.js/packages/next/dist/server/require.js:48
if we console.log the
pagesManifest
we will find the following output:Which means when using
getStaticProps
something withpagesManifest
breaks out. It is essential to make it work as often we use the locale from the context to render different static props…for i18n-routing there was no issues for path-based routing, did not test for domain based but we can prevent if it cause issues by putting a flag to check on
i18n.domains
andi18n.localeDetection
Even The generated html when disabling the flag @esseswann mentioned renders correct html lang based on the language
apart from the adding
getStaticProps
issue, I dont see any blockers for next.js to prevent static rendering with i18n support. If I can get some pointers on which files handle the build logic for pagesManifest and locale I would be happy to spend time to work on it and open a PR.It is really sad that such popular framework would not support multilanguage static rendering which would open doors to larger adoption by developers looking into static generators.