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

locales and defaultLocale in config not actually required #1146

Open
finkrer opened this issue Sep 22, 2023 · 1 comment
Open

locales and defaultLocale in config not actually required #1146

finkrer opened this issue Sep 22, 2023 · 1 comment

Comments

@finkrer
Copy link

finkrer commented Sep 22, 2023

What version of this package are you using?

2.5.3

What problem do you want to solve?

I want to have pages called /en/ and /${locale}/ in general that implement custom functionality (such as language switching via cookies).

The problem is that Next.js treats these routes in a special manner and ignores pages with these names.

It turns out that happens because next-translate forwards its locale config to the Next config, specifically the locales array.

In fact, it seems that it is the only thing being done with locales and defaultLocale. I have a full production project with several locales, and removing these locales from the config changes nothing.

Unfortunately, it seems that next-translate has a default defaultLocale that is set to 'en'. For that reason, it is impossible to omit these properties, as the default locale is not found in locales and an error is thrown.

Right now I worked around this by filling these properties with the 'default' locale, basically a junk locale to satisfy the package.

What do you think is the correct solution to this problem?

  1. defaultLocale should not have a default value.
  2. The package should expect that these properties may be omitted, in case the project does not require Next's built-in locale routing.
  3. Perhaps it should be made clear how exactly they are used and what relation they have to the same properties in next.config.js.

Are you willing to submit a pull request to implement this change?

No.

@aralroca
Copy link
Owner

aralroca commented Sep 29, 2023

I don't remember the reason for this default, but it doesn't make sense to me either. Feel free to do PR, it's here: https://github.com/aralroca/next-translate-plugin/blob/7977c9af6978a22bb471b0c80071aaf2c8b00776/src/index.ts#L31 If all tests pass by removing it, it will be that it was unnecesary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants