Activities

HapLifeMan

HapLifeMan posted a new bug report

nuxt-i18n •

bug Can't read property 'locale' of undefined

Version

v5.3.0

Reproduction link

https://github.com/HapLifeMan/nuxt-i18n-issue

Steps to reproduce

1) Clone git repository
2) Generate files with npm run generate
3) Open local server on dist/ folder
4) Try to access /, see error

What is expected ?

As the route generation strategy is configured on prefix, and there is no forced rootRedirect, it is expected that we are redirected to /fr or /en depending on the browser language.

What is actually happening?

Actually, no index.html file that redirect us to localized routes is generated in the dist folder.
We're stuck on the / with no redirect (personally, I have an error Can't read property 'locale' of undefined.).

Additional comments?

Everything is working fine with npm run build or npm run start, we are redirected correctly.
But I want to have a fully static website with a working root redirection…
Actually to fix temporarily the problem, I defined fr as my default locale (strategy prefix_except_default).

harmnot

harmnot posted a new question

nuxt-i18n •

key is not string

when. I call {{ $t("homepage.p") }} it always failed, I follow the setting of the contributor Paul,

tappat

tappat posted a new question

nuxt-i18n •

this.$nuxtI18nSeo is not a function

I'm trying to setup the SEO metadata generation as explained in https://github.com/nuxt-community/nuxt-i18n/blob/master/docs/seo.md

// nuxt.config.js
...
modules: [
  ['nuxt-i18n', {
    locales: [
      {
        code: 'se',
        iso: 'sv-SE'
      },
      {
        code: 'en',
        iso: 'en-GB'
      },
      {
        code: 'no',
        iso: 'no-NO'
      }
    ],
    seo: false,
    defaultLocale: 'se',
    vueI18n: {
      fallbackLocale: 'en',
      messages: {
        se: {
          welcome: 'Välkommen'
        },
        en: {
          welcome: 'Welcome'
        },
        no: {
          welcome: 'Velkommen'
        }
      }
    }
  }]
],
....

// layouts/default.vue
export default {
  head () {
    return this.$nuxtI18nSeo()
  }
}

Translations and switching between them works perfectly fine

<nuxt-link :to="localePath('index', 'se')">
  {{ $t('home') }}
</nuxt-link>
<nuxt-link :to="switchLocalePath('en')">
  English
</nuxt-link>

Once this.$nuxtI18nSeo() is called in head() an error is thrown that says "this.$nuxtI18nSeo is not a function"
Anyone have a clue about this one?

harmnot

harmnot posted a new question

nuxt-i18n •

how to change head meta data when switch the language

is there anyone ask that question yet ? if yes, please give me the link to read this question, if not, how to do that ?
I want to change the head tittle and description each user switch the language , how can I do that ?? I do love to get some help, I am. a beginner for this :D

appinteractive

appinteractive posted a new question

nuxt-i18n •

no_prefix mode

We are building a social network and do not and dont want to prefix any of our urls. Also do we dont want to use extra domains for the languages.
The question therefore is: Is there a way to switch the locale lazy: true without the need for reflecting it in the url?

I tried to use the store method but it does not load the given locale so its not working. And the parsePages: false does not have any effect ether.

Any suggesionts?

SnirShechter

SnirShechter posted a new question

nuxt-i18n •

Vue i18n option not working?

When inserting to options
{
VueI18n:{
missing(){
// Some function to do something
}
}
}

Seems like "missing" function is not working… still appears as null. note that other options(including options inside VueI18n) work just fine.

What am I doing wrong?

Thanks!

farhadniaz

farhadniaz posted a new question

nuxt-i18n •

nuxti18n and vuelidate just can't work together

i use nuxtjs and nuxti18n and vulidate to create a project , but when using nuxti18n and vuelidate in a page, it cause bug

the bug:
it don't let thew view to be render in correct way , i have to use this.$forecUpdate

manniL

manniL posted a new feature request

nuxt-i18n •

idea docs: don't suggest to provide a function for lazy loading
Zsavajji

Zsavajji posted a new bug report

nuxt-i18n •

bug Warning loop since router update in nuxt 2.3.4/1.4.5

Version

v5.4.4

Reproduction link

https://codesandbox.io/s/y7pqv48y19

Steps to reproduce

Navigate to the dynamic route, console is spammed with loop of "[vue-router] missing param for named route "test-all___en": Expected "0" to be defined", in client when navigating, or in server when going directly.

What is expected ?

Should not produce warnings.

What is actually happening?

Produces warnings when the route is manually localized in nuxt config.

Additional comments?

This is maybe a consequence of the new handling of dynamic route params in vue-router 3.0.2. Also happens in nuxt 1.4.5, which has the updated vue-router.

thariddler

thariddler posted a new question

nuxt-i18n •

Is it possible to change locale without changing the route?

What if I need to change just my interface language, not actually url path, content etc. Is this possible with this module?

ShenTengTu

ShenTengTu posted a new question

nuxt-i18n •

Can not load langDir? (Module not found: Error: Can't resolve '~/lang' in '.nuxt\nuxt-i18n')

Version

v5.4.3

Reproduction link

none

Steps to reproduce

I import nuxt-i18n with config as below:

['nuxt-i18n', {
  vueI18n: {},
  vueI18nLoader: true,
  locales: [
    { name: 'English', code: 'en', iso: 'en', file: 'en.js' },
    { name: '繁體中文', code: 'zh-Hant', iso: 'zh-Hant', file: 'zh-Hant.js' }
  ],
  defaultLocale: 'zh-Hant',
  strategy: 'prefix_and_default',
  lazy: true,
  langDir: 'lang/',
  rootRedirect: null,
  detectBrowserLanguage: {
    useCookie: true,
    cookieKey: 'i18n_redirected'
  },
  differentDomains: false,
  forwardedHost: false,
  seo: true,
  baseUrl: '',
  vuex: {
    moduleName: 'i18n',
    mutations: {
      setLocale: 'I18N_SET_LOCALE',
      setMessages: 'I18N_SET_MESSAGES'
    }
  },
  parsePages: true,
  pages: {},
  beforeLanguageSwitch: () => null,
  onLanguageSwitched: () => null
}]

my files structure:

my-project/
├── lang/
│   ├── en.js
│   ├── zh-Hant.js
├── nuxt.config.js

in lang file:

export default {
  welcome: ''Welcome''
}

What is expected ?

Eable Lazy-load translations and setting langDir, building project successful without error

What is actually happening?

Under NODE_ENV: development, building project failed an get error as below:

 ERROR  Failed to compile with 1 errors 

Under NODE_ENV: production, building project failed an get error as below:

ERROR in ./.nuxt/nuxt-i18n/utils.js
Module not found: Error: Can't resolve '~/lang' in 'd:\MainWorkSpace\WORKPROJECT\aifa-front-end-nuxt-pwa\.nuxt\nuxt-i18n'

Additional comments?

In .nuxt/nuxt-i18n/utils.js :

 const module = await import(/* webpackChunkName: "lang-[request]" */ '~/lang/' + file)
rchl

rchl posted a new bug report

nuxt-i18n •

bug Not able to match locale properly on dynamic routes

Version

v5.3.0

Reproduction link

https://codesandbox.io/s/ly9pnqvp79

Steps to reproduce

  1. Open codesandbox testcase
  2. Add /us to the URL

What is expected ?

Page shows 'US' in big letters

What is actually happening?

Page shows 'FR'

Additional comments?

This error happens with dynamic nuxt routes. Those are named with _.vue (or _slug.vue but I haven't checked those).

The bug seems to be in the order in which routes are generated. For example in this case:

['nuxt-i18n', {
            locales: [
                {code: 'pt', iso: 'pt-PT', file: 'pt.json'},
                {code: 'fr', iso: 'fr-FR', file: 'fr.json'},
                {code: 'us', iso: 'us-US', file: 'us.json'},
                // ...
            ],
            // ...
            defaultLocale: 'fr',
        }],

routes are generated in the order in which languages are defined in locales array. With this setting, generated routes will look like this:

routes: [
        {
                path: "/pt/*",
                component: _865a92ea,
                name: "all___pt"
        },
        {
                path: "/*",
                component: _865a92ea,
                name: "all___fr"
        },
        {
                path: "/us/*",
                component: _865a92ea,
                name: "all___us"
        }
],

As you can see, the 'catch-all' route (default language) was placed before more specific 'us' route. With this setup, 'us' route is inacessible due to routes being matched by iterating routes in the order they are defined.

Problem can be fixed by generating routes in proper order.

Wicpar

Wicpar posted a new question

nuxt-i18n •

Nuxt generate with differentDomains

Hello,

I am using nuxt and generating it for spring.
I use a differentDomains approach to the locale (used to be an MVC website).
It is unable to generate with differentDomains: true.
I am unwilling to change from domain based locale to /lang based locale because it will break all links to our site.

So i generated without the option.
I configured Spring to serve locale files based on if they are in the /lang root directory, but the /lang in vueRouter interferes with the dynamic page building.

How can i generate the different locales in their respective lang folder, but keep the generation like the result of differentDomains when true, with the server handling the lang based on the url for serving content.

Melchyore

Melchyore posted a new question

nuxt-i18n •

Remove locale prefix from URL

Hello!

Is it possible to remove locale from URL and use another way to detect it?

I want to avoid URLs like : /en/about, /fr/about and just use : /about.

therddlr

therddlr posted a new bug report

nuxt-i18n •

bug The title in head is blink when change locale

Version

v5.3.0

Reproduction link

https://github.com

Steps to reproduce

I set my head() in index.vue. The problem is when I change locale or navigate to another route I see title blink.

If I remove nuxt-i18n or set seo: false everything ok.

head () {
  title: `!!MY TITLE`
}

output.gif

What is expected ?

No blink

What is actually happening?

Blink

Yama-Tomo

Yama-Tomo posted a new question

nuxt-i18n •

How to fix time lag rendering when switching language?

relate #129

  • version 5.4.4

  • nuxt.config.js

{
  locales: ['en', 'ja'],
  strategy: 'prefix',
  parsePages: false,
  defaultLocale: 'en',
  vueI18n: {
    messages: {
      en: {
        hellow_world: 'Hello world!'
      },
      ja: {
        hellow_world: 'こんにちは世界!'
      },
    }
  }
}

I have a problem when switching language.

see bellow example

4WJJvEaCAI.gif

There is a time lag in the rendering of i18n contents and main contents

I expect rendering of synchronization

How do I fix it?

therddlr

therddlr posted a new bug report

nuxt-i18n •

bug Page transition broken with nuxt-i18n

Version

v5.3.0

Reproduction link

https://github.com

Steps to reproduce

I have simple fade page transition

.page-enter-active {
  backface-visibility: hidden;
  will-change: opacity;
  opacity: 1;
  transition: opacity 450ms linear;
}

.page-leave-active {
  backface-visibility: hidden;
  will-change: opacity;
  opacity: 1;
  transition: opacity 450ms linear;
}

.page-enter {
  opacity: 0;
}

.page-leave-active {
  opacity: 0;
}

The problem is, when I change locale, text content changes instantly while page transition is not complete.
In result I have a blink of content.

Is there'a a way to solve this?

What is expected ?

No blink, smooth transition

What is actually happening?

Transition broken, content blink

shrawanx

shrawanx posted a new question

nuxt-i18n •

detectBrowserLanguage not working on 5.4.4

I am using nuxt-i18n v 5.5.5 .
As told in the documentation i have kept my settings option as
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'mycustomcookie_name'
}
When the user selects a different locale , as i have two locales in my app , Whenever the user again visits the page the default locale is shown instead of the language chosen by the user .

therddlr

therddlr posted a new question

nuxt-i18n •

Provide an example of using

Where I can see a working example?

Capu-zennio

Capu-zennio posted a new question

nuxt-i18n •

Browser detection is not working with nuxt generate.

Since the browser detection is done in the middleware, it doesn't fire when loading a static html page created with nuxt generate.

Is this intended or a bug?