Activities

furyscript

furyscript posted a new feature request

nuxt-i18n •

idea Set construction with children route

What problem does this feature solve?

With this feature, we could know three of APP and get parents/children route.
This can be useful for breadcumbs in a site.
At this moment the routing construction has a limit that all route is in the same level without using children props of vue router.

honzabilek4

honzabilek4 posted a new bug report

nuxt-i18n •

bug Meta og:locale shouldn't contain name property

Version

v5.3.0

Reproduction link

https://codesandbox.io/s/z38klo3lrx

Steps to reproduce

Meta tags are included by default, when using the plugin.

What is expected ?

The og:locale meta tag should look like following:
<meta property="og:locale" content="en_GB" />
More info:
http://ogp.me/#optional

What is actually happening?

The tag has currently the following format:
<meta data-n-head="true" data-hid="og:locale" name="og:locale" property="og:locale" content="en_US"> Where the name is an extraneous attribute and the whole tag is being ignored.

Here's an output from facebook sharing debugger:
Screenshot 2019-02-16 at 15.22.25.png

Additional comments?

Is there any reason why the name attribute is present?
If not, I'll add a pull request for this.

davecoggins

davecoggins posted a new bug report

nuxt-i18n •

bug Vuex store current locale is out of sync when swithing between locales if lazy loading is enabled

Version

v5.3.0

Reproduction link

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

Steps to reproduce

Have lazy loading enabled and then switch between locales on frontend using the switchLocalePath helper.

What is expected ?

The vuex store locale value should update

What is actually happening?

It uses the previous locale value instead which means it lags by one locale as you switch between multiple locales

Additional comments?

I have tracked in down to the generated code in .nuxt/nuxt-i18n/middleware.js in the if statement checking if lazy loading is enabled the generated code has syncVuex(locale, messages) but it should be syncVuex(newLocale, messages)

Ace plugin btw :)

pierbettassa

pierbettassa posted a new bug report

nuxt-i18n •

bug "Template src not found:" when using Electron builder

Version

v5.3.0

Reproduction link

https://github.com/nuxt-community/electron-template

Steps to reproduce

Clone template repository
Install and setup nuxt-18n as described in https://github.com/nuxt-community/nuxt-i18n
Build: npm run build
Open app created in dist folder

What is expected ?

Nuxt.js app should work inside electron like in a standard browser.

What is actually happening?

Empty page in Electron browser, error FATAL Template src not found: <project_path>\dist\win-unpacked\resources\app.asar\node_modules\nuxt-i18n\src\templates\.eslintrc.js is displayed in parent shell.

Additional comments?

This problem is originated in src/index.js, line for (const file of readdirSync(templatesPath)) {.
The issue is caused by readdirSync function, see https://github.com/electron/asar/issues/103
Workaround/solution: remove the trailing path separator from TEMPLATES_DIR value exported in src/helpers/constants.js.

francoislevesque

francoislevesque posted a new feature request

nuxt-i18n •

idea Disable route translations for a whole app section

What problem does this feature solve?

We are currently building an app with a public section and an admin (protected) section. We need to make the public part fully translated (routes and texts). However, this is not essential for the admin part, since it does not need to be SEO friendly. However, the admin section still needs to show the text in the user's language. The current language does not come from the URL, but from the user's preferences.

I could build the entire admin section directly with vue-i18n since it does not need url translations. However, I would still need to disable nuxt-i18n on all admin routes (~60 routes), this seems pretty tedious… I haven't found a way to disable URL translations on a route group.

If there's a way, it should be added to the documentation, else I think it would be a pretty handy feature.

What does the proposed changes look like?

One way of doing this could be to add
nuxtI18n: false on a layout. This would disable route translations on pages using this layout.

gianniskarmas

gianniskarmas posted a new question

nuxt-i18n •

Is $t('example', 'locale') supported?

How to translate a specific key in a language that is different from the global locale $i18n.locale with nuxt-i18n?

Vue-i18n is using the $t('example', 'locale') and the vuex-i18n is using the $tlang('example', 'locale') but for some reason I keep getting:
[vue-i18n] Cannot translate the value of keypath 'products'. Use the value of keypath as default.

{{ $t('example', 'fr') }}
rchl

rchl posted a new feature request

nuxt-i18n •

idea Support passing path to localePath for easier resolving of dynamic routes

What problem does this feature solve?

localePath takes either string or object.
String is expected to be route's internal name.
Object, with current implementation of localePath, will be passed to VueRouter's resolve function but the name property will get ___[locale] appended to it.

The problem is that the object variant expects name to be set, otherwise it will create name value like undefined___[locale] and route will not match.

Given that it won't work to pass an object with just {path: '/about'}, for dynamic routes like pages/_.vue, we must instead do an awkward localePath call like localePath({name: 'all', params: {0: 'about'}}) (haven't really tested but I think it should work). This is IMO too cumbersome and what's more, it requires knowledge of internal route's name. It's basically not user friendly.

What does the proposed changes look like?

It should be possible to call code below to get localized path to dynamic route

localePath({path: '/about'});

and let router figure out the path.

Note that with PREFIXANDDEFAULT mode, it should ideally only return path with locale prefix added, if resolving to non-default language OR when current route includes locale prefix.

So (with en being default locale):

  • /about >> localePath({path: '/about'}) >> /about
  • /en/about >> localePath({path: '/about'}) >> /en/about
  • /fr/about >> localePath({path: '/about'}) >> /fr/about
BorysTyminski

BorysTyminski posted a new question

nuxt-i18n •

Language of description meta tag

Is it possible to translate description meta tag? If yes is there some notes in documentation about it? I can't find any informations.

Also my second question is, because I'm currently using vuex-i18n package and I'm planning upgrade to this package but is translated text pre-rendered?

Currently at my app when I visit .de extension I got text in german but when I press ctrl+U (show code) inside HTML markup I see text in english which is default locale. I want text to be pre-rendered so when I visit .de text which goes to browser should already be in german.

do-web

do-web posted a new question

nuxt-i18n •

This is the most defective nuxt extension i have ever seen
  • Multi domain not working -> Generates wrong links.
  • Using nuxt generate - Multi domain is not working at all
  • Language redirects also not working at all with nuxt generate
    ….
    Sorry but this extension is useless. It takes more time to fix this errors then to create a new one.
r3j3c73d

r3j3c73d posted a new question

nuxt-i18n •

Nuxt-Validate along side nuxt-i18n translation problem

Hi, I'm developing multilingual SSR with Nuxtjs. I'm using nuxt-i18n to resolve multilingual problem but I want to use nuxt-validate in this repo https://github.com/lewyuburi/nuxt-validate.
I add this to my nuxt-config.js

[
  'nuxt-validate',
  {
    lang: 'fa'
  }
]

Also I was used nuxt-i18n and it's work correctly and also I can't pass two language or more to it.
What can I do for this?
I you have another option for validation it's very good for me. thanks

andrade1379

andrade1379 posted a new question

nuxt-i18n •

Can Nuxt-i18n locale, messages, and path be programatically set?

I am using a third party service to geolocate users and I'm able to set the LOCALE based on the data that I'm getting back from the providers API, BUT can't seem to figure out how to then do:

  1. Redirect the user to the correct locale. For example: /de
  2. Load or set the correct messages for locale de

I've tried store.commit('i18n/I18NSETLOCALE', locale) where locale is set to 'de'. That seems to work when inspected using Vue dev tool in Chrome but setting the correct messages and updating URL does not seem to work.

Is there a preferred way to go about this?

andrade1379

andrade1379 posted a new feature request

nuxt-i18n •

idea Allow for alternative language detection

What problem does this feature solve?

Currently, Nuxt-i18n has an option to allow for browser detection which is great but not always accurate. It would be nice to allow for an alternative source to detect users language preference.

What does the proposed changes look like?

I'm proposing an option to allow for an alternative provider to detect a users language needs. For example, a geolocation service that provides an API that returns geodata.

In this particular instance my app is in SPA mode.

nuxt.config.js:

detectBrowserLanguage: {
            api: "https://someAPI.com/location", // Just as an example of how this can be checked
            useCookie: true,
            cookieKey: 'i18n_redirected'
        },

middleware.js:

if (detectBrowserLanguage) {
let browserLocale

    if (useCookie && (browserLocale = getCookie()) && browserLocale !== 1 && browserLocale !== '1') {
    } else if (isSpa && apiOption) {
        browserLocale = store.state.geoData.country.toLowerCase();

Something like that. I've made these edits to middleware.js and it's working for me. But I'm also seeing that an entry is made to the history then I'm redirected to the proper prefixed page.

What I would expect to happen for example if someone comes to '/' that only one entry is made to the history. There needs to be some type of check if route is the same then no entry is made. Maybe this is something that needs to happen as a plugin?

jovanmaric

jovanmaric posted a new bug report

nuxt-i18n •

bug this.$i18n.locales is undefined when using yaml-loader

Version

v5.3.0

Reproduction link

https://github.com/jovanmaric/nuxti18n-yaml

Steps to reproduce

  • Start with yarn dev.
  • Open console to see this.$i18n.locales outputting an array
  • Stop server
  • Uncomment the build configuration in nuxt.config.js
  • Start with yarn dev
  • Open console to see undefined

What is expected ?

That this.$i18n.locales returns the locales array even when using <i18n> component tags.

What is actually happening?

It seems like either vue-i18n-loader or yaml-loader are polluting the this.$i18n namespace

Additional comments?

I've looked at the src, but im not sure how to fix this without side effects. this.i18n seems to be where Vue-i18n is bound to by default, and nuxt-i18n extends on this behaviour.

sindael

sindael posted a new question

nuxt-i18n •

Lazyload custom paths in nuxt config?

Hi. I'm working on the internalization of my website and the nuxt-i18n has served me great so far. However, I haven't figured out how to fetch and load translations for the path from a server. With the documentation I got the lazyloading of locales going, but it seems this is not implemented in case of the pages option (i. e. setting custom paths in nuxt.config.js).

This is my config

  // nuxt.config.js
  modules: [
    ['nuxt-i18n', {
      locales: [
        {
          name: 'Czech',
          code: 'cs',
          iso: 'cs-CS',
          file: 'cs-CS.js',
        },
        {
          name: 'English',
          code: 'en',
          iso: 'en-US',
          file: 'en-US.js',
        },
      ],
      strategy: 'prefix_except_default',
      langDir: 'lang/',
      lazy: true,
      defaultLocale: 'cs',
    }],
  ],

Can I do, in some way, something along these lines?

  modules: [
    ['nuxt-i18n', {
      ...
      pages: [
        {
          name: 'Czech',
          code: 'cs',
          iso: 'cs-CS',
          file: 'pages-cs.js',
        },
        {
          name: 'English',
          code: 'en',
          iso: 'en-US',
          file: 'pages-en.js',
        },
      ],
    }],
  ],

I would be content with the component approach as well. However, because the nuxtI18n is a property and not a function, I do not have access to Nuxt (this) and thus neither to the app's store. If the first option is impracticable, is there a way how to pass to the nuxtI18n property a value from the store? Something like this.

  // contact.vue
  nuxtI18n: {
    paths: {
      cs: this.$store.state.pages.contact.cs
      en: this.$store.state.pages.contact.en
    },
  },
ruzpuz

ruzpuz posted a new question

nuxt-i18n •

A way to inject i18n to nuxt middleware

Hello,
Is there a way to inject i18n to nuxt middleware so I can do stuff with it before page rendering?

hmaesta

hmaesta posted a new question

nuxt-i18n •

Get translated string inside head()

For SEO proposes, I need translated strings for title and description.

I am trying:

head () {
      return {
        title: this.$i18n('Head.Title'),
        meta: [
          {
            hid: 'description',
            name: 'description',
            content: this.$i18n('Head.Description')
          },
        ],
      };
    },

But console returns that this.$i18n is not a function.

On another non-Nuxt project I just import i18n with import { i18n } from '@/i18n', but I don't know how to achieve that with Nuxt.

tronstoner

tronstoner posted a new bug report

nuxt-i18n •

bug Encoding custom paths breaks RegExps (introduced in #145)

Version

v5.3.0

Reproduction link

https://github.com/tronstoner/nuxt-i18n-bugreport

Steps to reproduce

1- git clone https://github.com/tronstoner/nuxt-i18n-bugreport.git
2- npm install
3- npm run dev
4- open console in browser
4- go to http://127.0.0.1:3000
5- Error: [vue-router] missing param for named route "foo-id___de": Expected "id" to match "%5Cd+", but received "666"

What is expected ?

RegExps in custom paths in translations should be left untouched.

What is actually happening?

encodeURI() breaks custom paths. e.g:

"/foo/:slug-:id(\\d+)"
becomes:
"/en/foo/:slug-:id(%5Cd+)"

A change introduced in:
https://github.com/nuxt-community/nuxt-i18n/commit/98c99459c5b7db2521c333e65a8ddf88b6287229

Additional comments?

I would be happy if for now encodeURI could be an just option (default: true), so we could simply take care of URI encoding ourselves before pushing paths to the router.

langald

langald posted a new question

nuxt-i18n •

When change locales in cycle, Vuex i18n.messages updates only firs cycle

When change locales in cycle, Vuex i18n.messages updates only firs cycle, then in state displayed the old messages value.

screenshot 2019-01-14 10 57 33

matsrietdijk

matsrietdijk posted a new question

nuxt-i18n •

How to force a locale on an ignored page?

Case: application has 2 languages (nl & en), default is 'nl'. prefix_except_default is used to generate routes (/ is 'nl', /en/ is 'en'). One route however should not be prefixed/multi language, it should only be available in 'en'.

Is it possible to force the locale for this one page to differ from the site default so all SEO and html attributes are correctly using the en-locale when visiting the page. Preferably without overriding the locale the visitor was using to browse the website (so all other links remain localized):

/* -> /blog: menu links aren't prefixed
/en/* -> /blog: menu links are prefixed with /en/

jdospina95

jdospina95 posted a new question

nuxt-i18n •

locale switches for the current page only

I am using the language switcher specified by paul in his nuxt-i18n example (https://github.com/paulgv/nuxt-i18n-example) and have my locale set to fallback english

['nuxt-i18n', {
locales: [{
code: 'en',
file: 'en-US.js',
name: 'English'
},
{
code: 'de',
file: 'de-DE.js',
name: 'Deutsch'
}],
defaultLocale: 'en',
fallbackLocale: 'en',
lazy: true,
langDir: 'lang/',
strategy: 'prefixexceptdefault'
}]

When I use the language switcher in a page it only changes it for that current page but then all the routing goes to default english. I want to be able to switch it to German from the langswitcher and then keep all the routing with the /de/

For example if I am in index it will be by default english, when I switch it to german it becomes /de/ but all the routing ignores the /de/ prefix and keeps routing with the english pages. How can I change this for the langswitcher to switch the locale of the i18n in every page and not just the current one