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:

Exploring Nushell, A Rust Powered, Cross Platform Shell

Exploring Nushell, a Rust-powered, cross-platform shell

Nushell is a modern, performant, extensible shell built with Rust. Explore its pros, cons, and how to install and get started with it.

Oduah Chigozie
Apr 23, 2024 ⋅ 6 min read
Exploring Zed, A Newly Open Source Code Editor Written In Rust

Exploring Zed, an open source code editor written in Rust

The Zed code editor sets itself apart with its lightning-fast performance and cutting-edge collaborative features.

Nefe Emadamerho-Atori
Apr 22, 2024 ⋅ 7 min read
Implementing Infinite Scroll In Next Js With Server Actions

Implementing infinite scroll in Next.js with Server Actions

Infinite scrolling in Next.js no longer requires external libraries — Server Actions let us fetch initial data directly on the server.

Rahul Chhodde
Apr 19, 2024 ⋅ 10 min read
Integrating Django Templates With React For Dynamic Webpages

Integrating Django templates with React for dynamic webpages

Create a dynamic demo blog site using Django and React to demonstrate Django’s server-side functionalities and React’s interactive UI.

Kayode Adeniyi
Apr 18, 2024 ⋅ 7 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