ivandotv / nextjs-translation-demo

Example of Next.js localization with Lingui.js

Home Page:linguijs-translation-demo.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updates for LogRocket article

thekip opened this issue · comments

https://blog.logrocket.com/complete-guide-internationalization-nextjs/

Hi, since this article was written, many things changed.

  1. nextjs is shipped by default with SWC compiler enabled, and babel is processing the code. LinguiJS has a dedicated plugin for SWC
  2. The code for loading catalogs is redundant https://github.com/ivandotv/nextjs-translation-demo/blob/main/src/utils.ts#L13-L20 if you already use webpack loader you don't have to compile them for production and complicating your build workflow. Just always use loader. It's doing absolutely the same as lingui compile but integrated in the build process so you don't have to do it manually.
  3. You can reuse nextjs configuration in lingui.config, and make things DRY example: https://github.com/lingui/swc-plugin/blob/main/examples/nextjs-13/lingui.config.js

It would be great if you can update an article, if you want i can create a PR with updates mentoned here.

It would be great if you could make a PR 👍

There are actually two ways how nextjs could be configured for current day. With SWC and with Babel. So it should be mentioned in the article.
I'm going to configure it with a SWC because it's a new default. But there are some people who still use babel for many resons (they use some custom plugins not ported to SWC)

It's better to update the page, because some code snippets mentioned there are confusing and require more work from developers. People just copypasting it to theirs project and then struggling with all this build steps and how they are related to each other

Especially it's true for this

The code for loading catalogs is redundant https://github.com/ivandotv/nextjs-translation-demo/blob/main/src/utils.ts#L13-L20 if you already use webpack loader you don't have to compile them for production and complicating your build workflow. Just always use loader. It's doing absolutely the same as lingui compile but integrated in the build process so you don't have to do it manually.