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

fix(differentDomains): handling of runtime domains from store #1183

Merged
merged 6 commits into from
Aug 12, 2021

Conversation

enwin
Copy link

@enwin enwin commented Jun 2, 2021

Following documentation https://i18n.nuxtjs.org/different-domains/#runtime-environment-variables. Configuring nuxt-i18n using differentDomains: true and defining the domains only in the store using with runtime environment variables end up with the warning Could not find domain name for locale xx.

The issue is that domain matching is made using options.normalizedLocales which is not updated with the domains from the store: https://github.com/nuxt-community/i18n-module/blob/master/src/templates/plugin.main.js#L370-L375.

This PR aims to update options.locales instead of app.i18n.locales since it is based on it, and update options.normalizedLocales so app.i18n.localeProperties contains the domain property and getLocaleDomain method can match a provided domain.

It also update the onNavigate method so we don't try to get the locale from the route when using differentDomains since the route wont contain the proper locale.

enwin added 2 commits June 2, 2021 14:38
…cales before extending the vue instance so app.i18n can get the store domains in the locale array and localProperties object. Fix getLocaleDomain not finding the correct domain when using differentDomains
@rchl
Copy link
Collaborator

rchl commented Jun 22, 2021

Sorry for the delay. I'll try to understand and review it soon.

For now have only one initial thought that it's likely not safe to assume that runtime configuration is supported by this module. Thus making some cases handle runtime configuration is still not likely gonna be flawless.

src/templates/plugin.main.js Outdated Show resolved Hide resolved
src/templates/plugin.main.js Outdated Show resolved Hide resolved
@rchl rchl changed the base branch from master to main August 3, 2021 18:54
@rchl rchl mentioned this pull request Aug 11, 2021
@netlify
Copy link

netlify bot commented Aug 11, 2021

✔️ Deploy Preview for nuxt-i18n canceled.

🔨 Explore the source changes: 8a50da7

🔍 Inspect the deploy log: https://app.netlify.com/sites/nuxt-i18n/deploys/61143c08b0da150007cac4cc

@rchl rchl changed the title fix: localeDomains using Runtime environment variables can't find domain name for locale fix(differentDomains): handling of runtime domains from store Aug 12, 2021
@rchl rchl merged commit 4d77019 into nuxt-modules:main Aug 12, 2021
@rchl
Copy link
Collaborator

rchl commented Aug 12, 2021

Thanks. Sorry for a very long wait.

@enwin
Copy link
Author

enwin commented Aug 12, 2021

No worries at all! Happy to take the discussion further if you want to improve the solution 👍

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

Successfully merging this pull request may close these issues.

2 participants