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

Allow setting available locales in the runtimeConfig #2888

Open
3 of 4 tasks
demtario opened this issue Mar 28, 2024 · 1 comment
Open
3 of 4 tasks

Allow setting available locales in the runtimeConfig #2888

demtario opened this issue Mar 28, 2024 · 1 comment

Comments

@demtario
Copy link

Describe the feature

Hey!
I'm currently working on uniform application, with support of many languages in different configurations.

Problem

Application is deployed independently in different environments, some of which have only a subset of all languages in the app. So, page A have english and polish, but site B has only polish. Currently I need to create different builds (different docker images) of the same application instead of just one. There is also no way to set a defaultLocale in the runtime, as it always reads the initial config.

I'm aware of the bundle.onlyLocales option, but it only works on buildtime.

Solution

Introduce an environment variable, that allows to enable or disable locales in the runtime.
My suggestion is: NUXT_PUBLIC_I18N_LOCALES_{code}_DISABLED, similar to existing NUXT_PUBLIC_I18N_LOCALES_{code}_DOMAIN env.

If given locale would be disabled, it wouldn't show in i18n.locales list. Basically it would not exists in the application.
I'm aware, that the messages for that locale would be included in the build, but i think it's fine.

Also, i suggest introduce NUXT_PUBLIC_I18N_DEFAULT_LOCALE environment variable. It would works just like i18n.defaultLocale but overrides default value.

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

@BobbieGoede
Copy link
Collaborator

The biggest obstacle to make this work would be route generation which uses defaultLocale and strategy at build time, I suppose this may not necessarily be an issue for strategy: 'no_prefix'.

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

No branches or pull requests

2 participants