i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Incorrect translation flashes when using differentDomains.

Open SebbeJohansson opened this issue 3 years ago • 7 comments

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.

SebbeJohansson avatar Aug 08 '22 17:08 SebbeJohansson

Something to note is that changing to ssr: false, makes it work correctly.

SebbeJohansson avatar Aug 08 '22 17:08 SebbeJohansson

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.

rchl avatar Aug 08 '22 17:08 rchl

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?

rchl avatar Aug 08 '22 17:08 rchl

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 avatar Aug 08 '22 17:08 rchl

@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?

SebbeJohansson avatar Aug 08 '22 20:08 SebbeJohansson

@rchl wait you meant nuxt Bridge? I thought you meant there was a bridge setting in i18n module! I'll try that.

SebbeJohansson avatar Aug 08 '22 20:08 SebbeJohansson

@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.

SebbeJohansson avatar Aug 08 '22 21:08 SebbeJohansson

current v8 alpha version, differentDomains has not been implemented yet. We will implement it after v8 alpha.1 is released.

Thanks!

kazupon avatar Aug 28 '22 13:08 kazupon