Incorrect translation flashes when using differentDomains.
Version
@nuxtjs/i18n: 7.2.3 nuxt: @nuxt/bridge-edge
Nuxt configuration
Please change to [x] if relevant for this issue:
- [X] Applies to a site deployed to a static server (site generated with
nuxt generate) - [ ] Applies to a site deployed to a server with a Node backend
@nuxtjs/i18n configuration
i18n: {
locales: [
{
code: 'en',
file: 'en.ts',
domain: 'localhost',
},
{
code: 'sv',
file: 'sv.ts',
domain: 'dragon.revolutionrace.se',
},
],
defaultLocale: 'en',
detectBrowserLanguage: false,
differentDomains: true,
// strategy: 'prefix',
// lazy: true,
langDir: 'translations/',
}
Reproduction Link
https://codesandbox.io/s/festive-mclean-6qcl21?file=/config/i18n.config.ts
Steps to reproduce
Create a nuxt bridge project with static target and add i18n-module. Add translations and locale with a specific domain.
What is Expected?
The correct translation to show up right away.
What is actually happening?
The default translation flashes for a split second before the correct translation is shown.
Something to note is that changing to ssr: false, makes it work correctly.
I kinda feel like this is expected/unfixable. The server-generated page will be generated with whatever locale is the default one so it will thus be visible before the client-side code kicks-in and changes the locale.
Actually, different locales should have different URLs (I see that you are using default strategy) so it shouldn't be an issue.
I wonder if it's related to using Bridge. Are you able to try without it?
Or maybe it's a problem specific to differentDomains... I seem to recall some issues like that. Possibly the only solution right now is to generate pages separately for each locale with different default locales...
@rchl sorry, trying without bridge how?
So the only solution might be to generate the pages manually? Will it still handle the domains? Is there documentation for that specifically?
@rchl wait you meant nuxt Bridge? I thought you meant there was a bridge setting in i18n module! I'll try that.
@rchl I can confirm that turning off nuxt bridge with bridge: false did work. I guess it will have to be fine until I can upgrade to nuxt3.
current v8 alpha version, differentDomains has not been implemented yet. We will implement it after v8 alpha.1 is released.
Thanks!