Activities

webcoderkz

webcoderkz posted a new question

nuxt-i18n •

TypeScript support

Do you plan to make it compatible with TypeScript?

jjhesk

jjhesk posted a new question

nuxt-i18n •

local storage preference issue
//获取用户浏览器优先选择语言
function get_language () {
  let strLang = localStorage.getItem ("lang");
  if (!strLang) {
    // first time set lang
    let language = "en";
    if (navigator.language) {
      language = navigator.language;
    }
    else {
      language = navigator.browserLanguage;
    }
    if (language.substr (0, 2) === "zh") {
      return "zh"
    } else {
      return "en"
    }
  } else {
    return strLang
  }
}

without using nuxt i am able to take localStorage for the default language choice. How do i have the same feature in nuxt because nuxt is hardcoded on the default config file.

lorenaramonda

lorenaramonda posted a new bug report

nuxt-i18n •

bug localePath can't fetch more than one dynamic root path

Version

v5.3.0

Reproduction link

https://codesandbox.io/s/codesandbox-nuxt-cqsx1?fontsize=14

Steps to reproduce

Create an architecture like this and add a navigation link to every page created using localePath({ name: NAMEOFTHEPAGE }).

Schermata 2019-10-19 alle 16.55.21.png

All of them are reachable except for _subcategory.vue in the root of the pages folder.

Please see codesandbox link to test it live.

What is expected ?

_subcategory.vue should properly displaying while linking it using:
localePath({
name: 'subcategory',
params: { subcategory: 'subcategory' }
})

What is actually happening?

_subcategory.vue in the root of /pages never shows up

Additional comments?

This properly works with a base nuxt installation without i18n activated

Josepdal

Josepdal posted a new bug report

nuxt-i18n •

bug Getting ERROR 404 on Google search console

Version

v5.3.0

Steps to reproduce

['nuxt-i18n', {
      parsePages: false,
      locales: ['es'],
      strategy: 'prefix',
      detectBrowserLanguage: {
        useCookie: true,
        cookieKey: 'i18n_redirected',
        alwaysRedirect: true,
        fallbackLocale: 'es'
      },
      vueI18n: {
        messages: {
          'es': require('./locales/es.json')
        }
      }
    }],

Here is my nuxt-i18n configuration.

What is expected ?

Redirect to /es as it is the only one available language.

What is actually happening?

Google Search Console is telling me that I have an ERROR 404 in / when crawling data from my website
error.png

Additional comments?

I have no problem entering the webpage, but my website is not being indexed by Google on their Search Engine because of this.

divisey

divisey posted a new bug report

nuxt-i18n •

bug page infinitely loading in spa mode

Version

v6.3.0

Reproduction link

https://github.com/divisey/nuxt-i18n-path-issue

Steps to reproduce

yarn

yarn dev

then visit http://localhost:3000/#/es/ in browser

What is expected ?

it should work well when url is either http://localhost:3000/#/es, http://localhost:3000/#/es/ or http://localhost:3000/#/es/?a=1

What is actually happening?

it works when url is http://localhost:3000/#/es, but page infinitely loading when you visit http://localhost:3000/#/es/, or when you have a
query like http://localhost:3000/#/es?a=1

Additional comments?

this issue does not appear in v6.0.0, maybe somewhere has a bug in the later version.

praburangki

praburangki posted a new question

nuxt-i18n •

Prefix Strategy - Redirect nested routes to prefix routes

Hi, I'm not sure if this has already been in the conversation.

Basically I have a similar issue with this one:
https://github.com/nuxt-community/nuxt-i18n/issues/45

I've already tried using rootRedirect: 'id'. If a user goes to the root page without prefix it will redirect to the prefix version.
But if user goes to:
/about --> 404
/id/about --> success

the use case is when user goes directly to that route then redirect it to the prefix version.

Is there a way to automatically redirect to the prefix version (to the defaultLocale) ?

praburangki

praburangki posted a new question

nuxt-i18n •

Prefix Strategy - Redirect nested routes to prefix routes

Hi, I'm not sure if this has already been in the conversation.

Basically I have a similar issue with this one:
https://github.com/nuxt-community/nuxt-i18n/issues/45

I've already tried using rootRedirect: 'id'. If a user goes to the root page without prefix it will redirect to the prefix version.
But if user goes to:
/about --> 404
/id/about --> success

Is there a way to automatically redirect to the prefix version (to the defaultLocale) ?

jeanphilippeds

jeanphilippeds posted a new feature request

nuxt-i18n •

idea Preload lang chunks

What problem does this feature solve?

Hello,

I'm working on a 30-lang website and it would be great to preload some lang chunks.

Ex:

Btw, is it possible to do so today?

Thanks,

LionelPaulus

LionelPaulus posted a new bug report

nuxt-i18n •

bug switchLocalePath() doesn't work in plugins

Version

v5.3.0

Reproduction link

https://codesandbox.io/embed/nuxt-i18n-switchlocalepath-bug-dbi7h

Steps to reproduce

Create a Nuxt plugin and try using switchLocalePath() in it.

What is expected ?

Function working: returning the locale path for the desired locale.

What is actually happening?

Function crashes with error:

Cannot destructure property params of 'undefined' or 'null'.
const { params, …routeCopy } = this.$route

Additional comments?

I'm using nuxt 2.10.0 and nuxt-i18n 6.3.0

jskorlol

jskorlol posted a new feature request

nuxt-i18n •

idea To get localeName instead of localePath ...

What problem does this feature solve?

If you use … Sometimes you need to pass params. Although it is not visible in the url, there are times when you have to pass data …
In this case, name can be used to pass params. I would like to have localeName.

What does the proposed changes look like?

We need a function that allows us to get the name, not the path of the router. localeName

gahabeen

gahabeen posted a new bug report

nuxt-i18n •

bug Not loading on server-side (empty translations on 1st load)

Version

v5.3.0

Reproduction link

https://noreproductionlink.com

Steps to reproduce

I'm using lazy loading just so I can extract for each language the right translations from a unique js object. (To understand, I've got everything in one place and I'm splitting it for each language).

I've got translations.js file which contains such kind of entries:
{ "hello": { "en": "hello", "fr": "bonjour" }, "hi": { "en": "hi", "fr": "salut" }}

which simplifies through a function (so it's dynamic / lazy) to the following files:
en.js { "hello": "hello", "hi": "hi" }
fr.js { "hello": "bonjour", "hi": "salut" }

What is expected ?

Translation shows up on first load

What is actually happening?

On firt load, I see [Object object] instead of the translations because somehow it doesn't resolve quick enough to the right language?

Additional comments?

I don't feel like the lazy/resolve part is done on the server (ssr), am I right? Could it be? That would solve my issue I think.

gahabeen

gahabeen posted a new question

nuxt-i18n •

Not loading on server-side (empty translations on 1st load)

I can't find how to solve this.

I'm using lazy loading just so I can extract for each language the right translations from a unique js object. (To understand, I've got everything in one place and I'm splitting it for each language).

But when I'm first loading I see [Object object] because somehow it doesn't resolve quick enough to the right language.

image

Anyone had the same issue?

superbiche

superbiche posted a new question

nuxt-i18n •

Don't break nuxt-community/router-module support

This is a way to re-open https://github.com/nuxt-community/nuxt-i18n/issues/88. There seemed to be people doing thumbs up but it ended stale/closed.

I think that nuxt-community/router-module is extracting some of the magic Nuxt does, which is really great.
No one in our team would like to explain Nuxt pages system to someone landing on a 50+ pages project with sometimes 4/5 levels of children.

For now I'm generating the localized pages with https://github.com/nuxt-community/nuxt-i18n/issues/88#issuecomment-537192941, but this is hacky and I'm only enjoying part of the automation that this gem is supposed to give.

Maybe there's a way to do this without rewriting much, like giving router-module users an opportunity to import a function from nuxt-i18n and pass the created Router as argument? A way to inject this like a plugin?

I don't have enough time to dig into the whole codebase, but would be happy to tinker with parts of it if someone gave me a hint about where to start :)

Anyway, thanks for this great module, using 50% of it already sparkled joy in my life ;)

lifenautjoe

lifenautjoe posted a new bug report

nuxt-i18n •

bug localePath utility function does not work with child pages

Version

v5.3.0

Reproduction link

https://codesandbox.io/s/example-i18n-xwgtf?fontsize=14

Steps to reproduce

Try to use localePath with a page and it's childrens.

      <nuxt-link
        :to="localePath('auth/login')"
      >Non working nuxt-link with localePath and page children</nuxt-link>

Watch it not work.

Try the same without localePath, see it work.

What is expected ?

localePath should be able to handle children pages

What is actually happening?

localePath can't handle children pages

nevenduranec

nevenduranec posted a new question

nuxt-i18n •

How to use @nuxtjs/axios with lazy load?
export default async (context) => {
    let lang = await context.$axios.$get('...');
    return lang;
};

context.$axios is not defined on the server, only on the client when you switch the language.

Also, the langDir language js file gets called twice when you do a hard reload, once on the server and then on the client.

cdefy

cdefy posted a new question

nuxt-i18n •

Cannot find module 'acorn-dynamic-import'

Hi,

I'm using nuxt-i18n since a few weeks (thanks for your work!) and did some version update without any issue until 6.2 or 6.1.2. Today I'm stuck at 6.1.1, if I try to update to latest version I've got the error message when doing npm run dev.

I can fix it by installing acorn-dynamic-import but I reckon it should be a temporary fix, doesn't it?

Any help will be really appreciated, thanks again for your work and your time!

umervservices

umervservices posted a new question

nuxt-i18n •

Using variables in $t() function

I am trying to parse dynamic variable in $t() like the following:

{{$t("contact[title]")}}

here the title is prop coming from the parent component but it giving output

contact[title]

is there any way to do that?

mrleblanc101

mrleblanc101 posted a new question

nuxt-i18n •

Cannot read property '_t' of null

Hi,
I have errors when using vue-i18n inside vue-meta using nuxt.
Should this be working correctly ?
this.$t is always defined in the head() function, but sometime this.$i18n is not defined and this.$t calls this.i18n.
Seems to only occur on the client-side.
The error never occurs on the server-side.

Exemple code:

head() {
    console.log('t', this.$t);
    console.log('i18n', this.$i18n);
    return {
        title: this.$t('home'),
    }
}

Capture d’écran, le 2019-09-26 à 14.53.43.png
Capture d’écran, le 2019-09-26 à 14.50.39.png

Snitovets

Snitovets posted a new bug report

nuxt-i18n •

bug Index page with dynamic routes corrupt path on any non-default locale with prefix

Version

6.2.1

Reproduction link

https://codesandbox.io/s/codesandbox-nuxt-y9vve?fontsize=14

Steps to reproduce

Trying to use dynamic routes on index page to apply single page for signin and signup. Just want to provide $route.params.id to <nuxt-child> and show user specific data. But path mess up on page reload. Also working well on nested routes like '/about/:id'.

What is expected ?

clean path on index page reload like /ru or /en

What is actually happening?

/ru/ru or /en/en

Snitovets

Snitovets posted a new question

nuxt-i18n •

window.location.href messing when index has dynamic routes

I don't know this is a bug or just I can't understand something. When locale is not default has /en or /ru, on page reload location goes /en/en or ru/ru. Working fine at default locale.

Page tree with issue:
Screenshot_1.png

Page tree which working as expected:
Screenshot_2.png