2021-10-14
2741
#nextjs
Ivan Vlatkovic
71779
Oct 14, 2021 ⋅ 9 min read

The complete guide to internationalization in Next.js

Ivan Vlatkovic

Recent posts:

Rxjs Adoption Guide: Overview, Examples, And Alternatives

RxJS adoption guide: Overview, examples, and alternatives

Get to know RxJS features, benefits, and more to help you understand what it is, how it works, and why you should use it.

Emmanuel Odioko
Jul 26, 2024 ⋅ 13 min read
Decoupling Monoliths Into Microservices With Feature Flags

Decoupling monoliths into microservices with feature flags

Explore how to effectively break down a monolithic application into microservices using feature flags and Flagsmith.

Kayode Adeniyi
Jul 25, 2024 ⋅ 10 min read
Lots of multi-colored blue and purplish rectangles.

Animating dialog and popover elements with CSS @starting-style

Native dialog and popover elements have their own well-defined roles in modern-day frontend web development. Dialog elements are known to […]

Rahul Chhodde
Jul 24, 2024 ⋅ 10 min read
Using Llama Index To Add Personal Data To Large Language Models

Using LlamaIndex to add personal data to LLMs

LlamaIndex provides tools for ingesting, processing, and implementing complex query workflows that combine data access with LLM prompting.

Ukeje Goodness
Jul 23, 2024 ⋅ 5 min read
View all posts

7 Replies to "The complete guide to internationalization in Next.js"

  1. Hi friend. It is a great article, With your tutorial I have set i18n in my next.js application with Lingui.js thanks.
    But I come with some issues that I resolve, may be it will help other if it happens.

    NB: I don’t use Typescript

    1
    – I get Module not found: Can’t resolve ‘fs’ when I add Lingui configurations and tools
    – to fix: configure .babelrc like this
    {
    “presets”: [“next/babel”],
    “plugins”: [“macros”]
    }

    2
    – In most Next.js application folder I think we don’t have “src” folder so the path where Lingui will look at translation can be an issue if they start with “src”, lingui extract will not return any data

    3
    – “npm run lingui extract” result as an issue because we don’t setup the script.
    – to fix: in script of package.json we can add :
    {
    “extract”: “lingui extract”,
    “compile”: “lingui compile”
    }

    4
    – In _app.js I remove “firstRender.current” because it blocks the rendering when I change the language in my menu.

    But again thank you I set translation in my app and may be I’ll add NEXT_LOCALE.
    Great article.

  2. Thanks, If you have any problems with the code you can file an issue on the github repo, and we can take it from there.

  3. Thank you for the writeup, wondering why you put the code for loading translations inside getStaticProps? This means you have the overhead of adding the same code to every page that relies on translated content. Wouldn’t offloading the message loading to _app also work, where you have access to the routers locale and can act accordingly?
    Cheers

  4. Hey, the locale works only If I visit the index root, but I load another url in my website, the locale doesnt work… the locale doesnt appear in my url. Do you know why?

  5. Hi Ivan, thank you for the great tutorial. I’m trying to migrate to App Router atm. Are you aware of any tutorial where the App Router is being used?

Leave a Reply