Skip to content

Can't access non-loaded lazy locales using $t #740

Closed
@matnowak

Description

Hello.

I was trying to put two different languages on the same page.
In my example, I'm trying to pull messages for two different languages i.e. polish and french.
The idea is to get language from a browser (fr) and compare it to language from URL(pl) which will show the message about difference and choose between two of them. That message should be in those two languages that I've got from the browser and URL.

I tried use v-t directive with the locale attribute, but it seems to not work as I expected.
Tried also $t with same effect.

After checking i18n object I had only current language messages (in this situation polish) and both strings were translated into polish only...

My nuxt-i18n config

  parsePages: false,
  locales: LOCALES,
  defaultLocale: process.env.NODE_ENV !== 'production' ? 'en' : 'en-gb',
  lazy: true,
  langDir: 'lang/',
  vueI18n: {
    fallbackLocale: 'en',
    silentFallbackWarn: true,
    formatFallbackMessages: true,
  },

Is there any possibility to use both languages on the same page?

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions