Activities

mcdmaster

mcdmaster posted a new feature request

nuxt-i18n •

idea Using 2-Letter Country/Region Code instead of Language Code in detectBrowserLanguage

What problem does this feature solve?

When there is a need to distinguish Chinese-Simplified and Chinese-Traditional, we will be happy to use country / region codes like CN or TW or HK or MO or SG as locale "codes" in our applications. Currently, main.js sees only the first 2-letter language code, for instance, 'zh' for entire Chinese locales that are apparently different one another. We all need to know that end-users in these areas are quite sensitive to distinguish their locales and that they dislike ambiguity in their mother tongues.

lukaVarga

lukaVarga posted a new bug report

nuxt-i18n •

bug syncRouteParams: false results in an error in plugin.routing when using switchLocalePath

Version

v6.7.0

Reproduction link

https://not-needed.com

Steps to reproduce

Add the following config to vuex:

        vuex: {
          syncRouteParams: false,
        },

Reload the server / page

What is expected ?

App should load and work

What is actually happening?

App fails to load with an error coming from plugin.routing.js - store.getters[${vuex.moduleName}/localeRouteParams](locale) is not a function.

Additional comments?

If syncRouteParams option is false, then the localeRouteParams getter within plugin.main.js does not get registered. However, switchLocalePath function within plugin.routing.js depends on localeRouteParams getter being present (if vuex and store are present, which both holds true with the configuration listed above)

gaugau3000

gaugau3000 posted a new question

nuxt-i18n •

use a yaml file for translation that work with hot reload

Hi,

I would like to know if there is an elegant way to use a yaml file for translations ?

I don't see this type of information in the documentation.

Many tks.

Have a nice day.

cawa-93

cawa-93 posted a new bug report

nuxt-i18n •

bug When you try to change the language, the URL fragment changes but the data on the page does not

Version

v6.7.0

Reproduction link

https://codesandbox.io/s/trusting-yalow-367bu

Steps to reproduce

  • Open the sandbox.
  • Use the link in the sandbox to change the language in my example

What is expected ?

The URL fragment changes and the text in the h1 changes

What is actually happening?

The URL fragment changes, but the text in the h1 remains unchanged

mathieumagalhaes

mathieumagalhaes posted a new bug report

nuxt-i18n •

bug Pull request #554 wrongly implemented.

Version

v6.7.0

Reproduction link

https://github.com/nuxt-community/nuxt-i18n/pull/554

Steps to reproduce

Please add following tests:

expect(window.$nuxt.localePath('/about-us', 'fr')).toBe('/fr/a-propos')
expect(window.$nuxt.localePath({ path: '/about-us' }, 'fr')).toBe('/fr/a-propos')

Which will fail as both will result in /fr/about-us instead of /fr/a-propos
Tested with master branch.

What is expected ?

localePath('/about-us', 'fr') to be /fr/a-propos

What is actually happening?

localePath('/about-us', 'fr') becomes /fr/about-us

Additional comments?

Using the older way with route names still works correctly, but this usage would make my life easier.

davestewart

davestewart posted a new question

nuxt-i18n •

How to route latin and cyrillic versions of the same language?

I have just received the translations for latin and cyrillic Serbian.

The ISO and code is the same for both (sr).

In order for the URL prefixing to work, I need to give them different codes to generate different URLs.

What should I do?

chrissyast

chrissyast posted a new question

nuxt-i18n •

Why is loadAndSetLocale called continuously?

If I put a breakpoint in middleware.js, main.js and loadAndSetLocale, when I am viewing the page, these breakpoints keep getting hit in Node DevTools. If I resume the script after one of the breakpoints, it just keeps hitting main then middleware then main etc…

The trace through middleware is:

// internal/process/task_queues.js#processTicksAndRejections()
// -> runMicrotasks()
// ->which then calls middleware.js // (I'm not sure how this happens).
// -> await app.i18n.setLocale(routeLocale || locale)

The trace through main.js is:

// server.js#createApp()
// -> main.js 
// ->  await loadAndSetLocale(locale, {initialSetup: true});

Is this a bug or is this expected behaviour? Is the await expecting a promise which is never returned? My Node/Nuxt experience is very limited at this point, so sorry if this is an obvious question.

adrianwix

adrianwix posted a new question

nuxt-i18n •

Change app locale before route change

I need to fetch some localize resources before going to the next route and for that I need to get the next locale. When going from www.hola.com/es to another lang e.g "/en". The middleware will print app.i18n.locale === es and route.path === www.hola.com/en. So the only way to get the next locale is parsing the path. I tried another option app.i18n.beforeLanguageSwitch this is called before the asyncData of the next page. But using async/await does not work because the callback does not wait for the resource to be fetched before continuing to the next route.

I have some resources being used in the navbar and some pages at the same time so they need to be globally available in the Vuex store.

Only option I found was to use strategy: 'prefix' and parse the path in the middleware.

Is it possible to return a promise in app.i18n.beforeLanguageSwitch?? To wait for the resources?

suryaiiit

suryaiiit posted a new question

nuxt-i18n •

Strategy: no_prefix issues

my nuxt.config

i18n: {
strategy: 'no_prefix',
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'locale-cookie',
fallbackLocale: 'en'
},
defaultLocale: 'en',
locales: [
{
code: 'en',
name: 'English',
iso: 'en-US',
file: 'english.js'
},
{
code: 'hi',
name: 'Hindi',
file: 'hindi.js'
}
],
lazy: true,
langDir: 'static/locales/'
},

if I comment out strategy everything works fine, when I uncomment strategery:"no_prefix" I get many of the following errors:

WARN [nuxt-i18n] Passing non-current locale to switchLocalePath is unsupported when using no_prefix strategy 20:09:48

WARN [nuxt-i18n] Passing non-current locale to localePath is unsupported when using no_prefix strategy 20:09:48

Also, the following are not executed when I click on the nuxt-link (with switchLocalePath)

export default function({ app }) {
app.i18n.beforeLanguageSwitch = (oldLocale, newLocale) => {
console.log('beforeLanguageSwitch:', oldLocale, newLocale)
}

app.i18n.onLanguageSwitched = (oldLocale, newLocale) => {
console.log('onLanguageSwitched:', oldLocale, newLocale)
}
}

Am I missing out on something? Please suggest.

simplenotezy

simplenotezy posted a new question

nuxt-i18n •

Translated link in multiple languages

How can I have a static link to a page, where the URL is shown depending on the current language?

<nuxt-link :to="localePath({ name: 'page', params: { slug: 'about-us' } })">

I need this for the footer of my application, where links are hardcoded in. In english the link is /about-us, however, in danish the link is: /da/om-os

I would expect something like:

<nuxt-link :to="localePath({ name: 'page', params: { en: { slug: 'about-us' }, da: { slug: 'om-os' } })">

lustremedia

lustremedia posted a new question

nuxt-i18n •

Documentation for rootRedirected is vague ...

If I set the option rootRedirected: to a relative path lets say '/en' it will redirect to http://en/ Does rootRedirected: only allow an absolute path?

If I use the prefix strategy for routes. How can I tell nuxtjs to redirect to the default locale when a user hits '/'? Do I need a combination of rootRedirect and routing strategy and browser locale selection?

The documentation is not very specific on how rootRedirect really works.

rikless

rikless posted a new question

nuxt-i18n •

next is undefined

Hello,

Since https://github.com/nuxt-community/nuxt-i18n/pull/630 when running on local env, I have this error

TypeError: "next is undefined"
NuxtJS 10
normalizeLocation
resolve
render
_render
updateComponent

There is no more information in the stacktrace, so I'm really lost :/

Louvki

Louvki posted a new question

nuxt-i18n •

Is having query params included in the href of alternate-hreflang tags intended?

What is the issue?
The href attribute in the alternate-hreflang meta tags from nuxtI18nSeo().link contain query params.
90091589_675534906547335_3491962158592294912_n.png

Why is this an issue?
From what I know the alternate-hreflang tags should work similiarly to that of a cannonical tag where it points to the original version of any page.

Is this intended behaviour?

cyrildewit

cyrildewit posted a new question

nuxt-i18n •

Deprecated dependency vue-i18n-extensions

Hi,

The vue-18n-extensions npm package is deprecated. The name has been changed to @intlify/vue-i18n-extensions.

I was trying to make a pull request with the updated package, but version 0.2.1 is not available in the new package registry.

We could upgrade to 1.0.1, but this version requires node >= 10.0 instead of >= 8.0. Node 8 is not maintained anymore according to https://nodejs.org/en/about/releases/

Are you open to a pull request that updates the package to v1?

Here's the announcement and the available versions.

dschewchenko

dschewchenko posted a new bug report

nuxt-i18n •

bug trailing slash on localized index page

I have:

  • 2 locales en and cn(for example)
  • underscore page(_.vue), for dynamic pages(data from backend).
  • nuxt-i18n, strategy: "prefixexceptdefault", defaultLocale: "en".
  • routes may to be without trailing slash at the end (example.com, example.com/cn)

If I use index.vue, all works as expected, but if I use _.vue, it cannot recognize cn locale
For _.vue works good, only with trailing slash at the end

Version

v6.6.0

Reproduction link

https://codesandbox.io/s/fancy-haze-27wr0

Steps to reproduce

  • go to /cn (without trailing slash on the end)
  • get info
  • you see "en" locale in console

What is expected ?

Go to /cn and get current locale "cn"
Also correct behaviour of switchLocalePath method

What is actually happening?

If you go to /cn, you will get current locale "en"
For now switchLocalePath method goes to "/cn/cn"(Chinese link) and "/cn"(English link) on "/cn" path

Additional comments?

I'm using underscore page (_.vue), because of dynamic data from backend

theo-bittencourt

theo-bittencourt posted a new bug report

nuxt-i18n •

bug Translation messages are not being loaded when locale is "en-US"

Version

v6.6.0

Reproduction link

https://codesandbox.io/s/thirsty-fast-7iqw9

Steps to reproduce

  1. Open the CodeSandbox link.
  2. Navigate do /en-US (in the inner browser)

What is expected ?

Load the translations correctly.

What is actually happening?

  1. Translation messages are not being loaded.

  2. The following warning is emitted on console:

    [vue-i18n] Cannot translate the value of keypath 'commons.helloWorld'. Use the value of keypath as default. 
    
  3. $nuxt._i18n.messages is empty.

Additional comments?

Investigation of the problem origin

loadAndSetLocale abort the translations loading when newLocale === app.i18n.locale:
https://github.com/nuxt-community/nuxt-i18n/blob/v6.6.0/src/plugins/main.js#L139

And app.i18n.locale is been defined as en-US on kazupon/vue-i18n:
https://github.com/kazupon/vue-i18n/blob/v8.x/src/index.js#L68

Workaround

I found a workaround but I don't know yet about the possible side effects:

// nuxt.config.js

i18n: {
  ...
  vueI18n: {
    locale: "---", // Defining an invalid locale to force nuxt-i18n to load translation
  }
  ...
}

Possible related thread on VueJS Forum:
https://forum.vuejs.org/t/i18n-cannot-translate-the-value-of-keypath/45334/4

linaslev

linaslev posted a new question

nuxt-i18n •

differentDomains: true but all language files are loaded

Hello,

I have an application that has 40 languages and we are using a differentDomains: true option because each language is on a different domain.

The problem is, that I only need the language of the domain that I'm on right now, however, the application still downloads a huge JS file with all the translations, which is most importantly blocking the user from interaction on the page until it downloads.

How can this be solved?

isuke01

isuke01 posted a new question

nuxt-i18n •

Hooks not working, nothing is changing when language swap.

Hey, please any more info/help?

Fresh install of nuxt.
NUXT: 2.11.0
Nuxt-i18n : 6.6.0
vue-meta: 2.3.3

I cant make those hooks work beforeLanguageSwitch and onLanguageSwitched.
Plugin is loaded correctly, I can log from file but those actions does not do anything. Whenever I switch langauge.

Also on page if I switch language using <nuxt-link :to="switchLocalePath('en')">English</nuxt-link> or any other lang code, just nothing is happening, except it adds to url lang slug.
{{ $t('hello') }} is not changing.
I have to refresh page to see difference. There is no errors in console.

This is my nuxt.config.js

export default{
    mode: 'universal',

    plugins: [
      "~/plugins/i18n.js",
      "~/plugins/mixins.js",
    ],

    buildModules: [
    ],

    modules: [
      'nuxt-buefy',
      '@nuxtjs/axios',
      ['nuxt-i18n', {
        locales: [
          {
            name: 'Italiano',
            code: 'it',
            iso: 'it-IT',
            file: 'it-IT.js'
          },
          {
            name: 'English',
            code: 'en',
            iso: 'en-US',
            file: 'en-US.js'
          },
        ],
        vuex:{
          preserveState: true
        },
        lazy: true,
        langDir: 'lang/',
        defaultLocale: 'en',
      }]

    ],
  }

it-IT.js:

export default {
    hello: 'Ciao a tutti',
    pages: {
      home: 'Pagina iniziale',
      contacts: 'Contatti'
    },
  }

And ofc. for english.

I tried with and without lazy, setup everything inside nuxt.config.js, nothing is working for me.
When Im logging this.$i18n.loadedLanguages in hook mounted it always return only the language that was set when I reload/refresh page.

What Im doing wrong?


SOLVED!

Actually if you set

detectBrowserLanguage: {
      alwaysRedirect: true // remove this settings actually solve my issue 
},
simplenotezy

simplenotezy posted a new feature request

nuxt-i18n •

idea Reduce bundle size

What problem does this feature solve?

I love this package. It is highly needed by the nuxt community. But it faces a huge challenge IMO: The bundle is pretty large.

What can be done to reduce the size? It's currently the package that takes up the most space (by more than 300% compared to the second), and it takes more than 3.3 seconds (!) to load on 3G. See attached screenshot.

The native vue-i18n module is only 22.2kB compared to 720kb (this package)

Screenshot 2020-03-09 at 00.02.27.png

What does the proposed changes look like?

Reducing bundle size, creating a "lite" version, or something third.

Graziel

Graziel posted a new feature request

nuxt-i18n •

idea allow custom pluralization

What problem does this feature solve?

https://kazupon.github.io/vue-i18n/guide/pluralization.html#custom-pluralization

What does the proposed changes look like?

add it to options like
beforeLanguageSwitch: (oldLocale, newLocale) => null,