next.js icon indicating copy to clipboard operation
next.js copied to clipboard

feat: allowing user to specify i18n cookie name on config

Open veimox opened this issue 3 years ago • 0 comments

Feature

Implements the feature as suggested in #24852. Our use case is that we have multiple apps managed by different teams and we want to have a frictionless experience through all of them. One part of it is to preserve the same language. Some of our apps are in NextJS and it would be great if we don't have to force other teams to follow the NextJS convention.

I have not added integration tests because the fixture is pretty much locked with the NEXT_LOCALE default cookie, which I think is right, but let me know what you think about that.

  • [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • [x] Related issues linked using implements #24852
  • [ ] Integration tests added
  • [x] Documentation added
  • [ ] Telemetry added. In case of a feature if it's used or not.
  • [ ] Errors have helpful link attached, see contributing.md

Documentation / Examples

  • [x] Make sure the linting passes by running yarn lint
  • [x] Added setting to the docs

How to test

  1. Create a i18n project. e.g. yarn create next-app --example i18n-routing i18n-app
  2. Check out this branch and link the project as per the guidelines
  3. Run the project with yarn dev
  4. Open a browser (e.g. Firefox) and add the NEXT_LOCALE cookie value to fr
  5. Go to localhost:3000 and check that it goes to the fr locale. So far so good.
  6. Now add the new property cookieName: custom to the next.config.js
  7. Add now a cookie called custom with value nl
  8. Go to localhost:3000 and check that it goes to the fr locale.
  9. Happy days

veimox avatar Feb 11 '22 15:02 veimox