Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 11.1 introduces i18n limits that blocks us from upgrading. #28157

Closed
gtothesquare opened this issue Aug 16, 2021 · 10 comments · Fixed by #28429
Closed

Release 11.1 introduces i18n limits that blocks us from upgrading. #28157

gtothesquare opened this issue Aug 16, 2021 · 10 comments · Fixed by #28429
Labels
bug Issue was opened via the bug report template.

Comments

@gtothesquare
Copy link

gtothesquare commented Aug 16, 2021

What version of Next.js are you using?

10.2.3 -> 11.1

What version of Node.js are you using?

14.x, 16.x

What browser are you using?

Chrome, Firefox

What operating system are you using?

macOS

How are you deploying your application?

next build and we then deploy it in our own infra. (Docker and kubernetes)

Describe the Bug

Currently we are using version 10 of next js. After the summer we planned to upgrade to 11. Then with the release of 11.1 we decided to jump directly to latest. We have a site that has 177 locales and it has been working fine (even on version 11.0). However, 11.1 introduced hard limit to 100 without explanation or warning or a workaround.

Here is the commit of the documentation https://github.com/vercel/next.js/pull/27542/files
And docs in prod
https://nextjs.org/docs/advanced-features/i18n-routing#limits-for-the-i18n-config

Expected Behavior

We can upgrade without issues given that it worked before.

To Reproduce

Create a next.config.js file with 100 more than i18n locales and then run next build.

@gtothesquare gtothesquare added the bug Issue was opened via the bug report template. label Aug 16, 2021
@orneryd
Copy link

orneryd commented Aug 18, 2021

This is a blocker for us as well and will force us to find a suitable alternative.

We would also like to be able to define /change the locales at runtime instead of needing to be configured up-front. (for multi-tenancy purposes)

@irmakcosarsahna
Copy link

Same problem

@ijjk
Copy link
Member

ijjk commented Aug 23, 2021

Hi, is unique content being generated for all 177 locales or are there so many locales being configured to ensure they are routed correctly?

Would ensuring the routing maps en-GB -> en help reduce the number of locales that need to be configured for your set-up?

Note: for each locale configured an additional version of each page is generated (unless using getStaticPaths and only the provided locale paths are generated)

@gtothesquare
Copy link
Author

Hi, thanks for the response.

Yes is unique content. We have like 80+ languages where the site is translated to. However, each country has its own content in official local language and in English.. So, even if we have 30+ sites in English the content varies for each.

Not sure if I understand your note, however what are you saying is that for each local a "copy" of the site is generated in the respective locale. Maybe is easier to see the use case: here is the index of all the sites generated https://www.volvocars.com/intl/legal

One question is why the 100 limit ? Will be interesting to understand the reasoning behind it.

@gtothesquare gtothesquare changed the title Release 11.1 introduces i18n limits that blocks our from upgrading. Release 11.1 introduces i18n limits that blocks us from upgrading. Aug 23, 2021
@ijjk
Copy link
Member

ijjk commented Aug 24, 2021

I see thanks for the details, the reason we put this limit in place was from potential performance impacts from having boundless locales configured. We also want to make sure users aren't accidentally creating extra locales by auto-generating them so having a limit in place is good.

The performance impacts mentioned comes into play for a few places one is during build-time which is from generating a version of each page in so many locales which may not be a problem for smaller sites but in larger ones can slow things down a noticeable amount e.g. 20 pages with 175 locales needs to generate 3500 versions (potentially requiring data be fetched each time in getStaticProps), another place is with increasing the size of NEXT_DATA which is inlined in the initial HTML for every request this isn't too impactful as locales are very short but is a point to consider as this can potentially increase HTML size by 1 - 2KB, and another place is with rewrites, redirects, and headers in next.config.js as each route added in these is currently prefixed with every locale unless using locale: false which adds complexity to checking against these routes for every request.

We are looking into optimizing these items along with a few others to ensure the best performance. This limit is definitely flexible and we used the fact that Google translate has 108 languages as prior art for deciding on the initial limit. I converted this hard error for hitting the limit into a warning and also added documentation for the caveats of statically generating pages with i18n enabled here.

@JohnDeved
Copy link

JohnDeved commented Aug 24, 2021

Hi, is unique content being generated for all 177 locales or are there so many locales being configured to ensure they are routed correctly?

Would ensuring the routing maps en-GB -> en help reduce the number of locales that need to be configured for your set-up?

Note: for each locale configured an additional version of each page is generated (unless using getStaticPaths and only the provided locale paths are generated)

for my case that would help, content would not be different across different countries.
how could the routing be archived?
@ijjk

@gtothesquare
Copy link
Author

@ijjk ahhh I see. Much appreciated. Thanks for the quick fix.

@JohnDeved
Copy link

@ijjk trying to do this as a workarround, sadly causes issues with links on the site, these will still redirect to "/en"

  async rewrites() {
    return {
      beforeFiles: [
        {
          source: '/:lang(\\w{2})-:country(\\w{2})/:path*',
          destination: '/:lang/:path*',
        },      
      ],
    }
  }

@ijjk
Copy link
Member

ijjk commented Aug 24, 2021

@JohnDeved there isn't currently a workaround using rewrites to achieve the mentioned behavior it will need to be added in next-server itself, I re-opened #28410 to track this there

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants