Activities

pschaub

pschaub posted a new question

nuxt-i18n •

x-default value

I think this module should also support the x-default value.

Especially if I use the prefix_and_default strategy it may be helpful to define a x-default value.

See: https://support.google.com/webmasters/answer/189077?hl=en

The reserved value hreflang="x-default" is used when no other language/region matches the user's browser setting. This value is optional, but recommended, as a way for you to control the page when no languages match. A good use is to target your site's homepage where there is a clickable map that enables the user to select their country.

WouterFlorijn

WouterFlorijn posted a new bug report

nuxt-i18n •

bug nuxt-i18n doesn't work with pm2

Version

v5.8.5

Reproduction link

https://dyme.app

Steps to reproduce

  • Install and configure nuxt-i18n.
  • npm run build
  • pm2 start npm --name "my-project" -- start
  • Configure nginx with proxy_pass http://localhost:3000

What is expected ?

The website works.

What is actually happening?

Every page shows a standard nginx 502.

Additional comments?

Note that the link provided is currently working because I rolled back to a version without nuxt-i18n.

When I run locally using npm run dev or npm run build + npm run start, everything works fine.

remychvn

remychvn posted a new question

nuxt-i18n •

Using translation management web service

I would like to use a platform for managing translation files.
Services such as transifex, Localize, POEditor… and many others !

But the json format used by nuxtjs-i18n is not standard if I understand correctly?

The idea is to publish the new translation files with each new version of the application so that translators can add/correct the translations before they go into production in a suitable interface.

Is this easily achievable? How to do that?

Thank you

taraskhvyl

taraskhvyl posted a new question

nuxt-i18n •

How to reload nuxtServerInit and async data

Hi!

When i changed lang all data in store stay the same. Changes only words in local files.
How to reload async data and nuxtServerInit for changed lang?

alexgil1994

alexgil1994 resolved the question #c224

nuxt-i18n •

Nuxt-i18n with custom SEO metadata of title and description for each page

I was wrong, I was inspecting it the wrong way (through page-source instead of opening the dev tools and view the elements that were generated).

I believe everything will work fine with something like :

 head() {
    return {
      title: this.$t("index.meta.title"),
      meta: [
        {
          hid: "description",
          name: "description",
          content: this.$t("index.meta.description")
        },
        ...this.$nuxtI18nSeo().meta
      ],
      htmlAttrs: {
        ...this.$nuxtI18nSeo().htmlAttrs
      }
    }
  }

to also ensure that the automatically generated SEO tags from nuxt-i18n will be combined with our custom ones.

edgarsn

edgarsn posted a new question

nuxt-i18n •

Router meta

Hi!

How can I add route meta fields to i18n routes?

https://router.vuejs.org/guide/advanced/meta.html

alexgil1994

alexgil1994 posted a new question

nuxt-i18n •

Nuxt-i18n with custom SEO metadata of title and description for each page

Hello, I am trying to implement nuxt-i18n in a project. Everything works great but I am trying to have in the head() of the pages a title and a description specific for each language. Is this possible? I am trying it through :

head() { return { title: this.$t("index.title"), meta: [ { hid: "description", name: "description", content: this.$t("index.description") } ] } }

The title does change dynamically but if one inspects the page-source then you can see that only the default language is showing even if you open the the page-source from another language like /de . What I want is to have the website able to be read in all languages with different SEO metadata for each.
My testing repo is https://github.com/alexgil1994/nuxt-nuxti18n-test
I would like to say that I have used previously vue-i18n instead and I was able to have the needed SEO, I just wanted to try the official module this time which works pretty good except of this (of which the fault is probably mine).

(Also in the module's page for SEO (https://nuxt-community.github.io/nuxt-i18n/seo.html#seo) the link for custom SEO is navigating to a 404.
Text in the docs that has the link: "To override SEO metadata for any page, simply declare your own head () method. Have a look at src/plugins/seo.js if you want to copy some of nuxt-i18n's logic"
Broken link: https://nuxt-community.github.io/src/plugins/seo.js )

Thank you for your time!

bugsel

bugsel posted a new question

nuxt-i18n •

nuxt.js generate and nuxt-i18n (localePath)

In my application, I use HTML pre-rendering through a nuxt generate, option routes: [], I receive a list in format: {endpoint: 'profile-id', id: '10001'} via API.

nuxt.config.js

import getAppRoutes from './utils/get-routes.js'
...
generate: {
    routes() {
      return getAppRoutes()
    } 
}
...     

Is there a possibility of generating final URL (/profile/100001/) through a nuxt-i18n, i.e. can I get access to app instance and next use method app.i18n.localePath (https://github.com/nuxt-community/nuxt-i18n/blob/master/docs/basic-usage.md)?

utils/get-routes.js

...
export default async function () {
    return axios.get('/api/v1/routes').then((res) => {
        return res.data.source.map((item) => {
            let url = '/profile/' + item.id + '/'  // <=== use app.i18n.localePath({name: item.endpoint, params: {id: item.id}}) here!
            return url
        })
    })
}
vodniciarv

vodniciarv resolved the question #c221

nuxt-i18n •

Long time for loading when use 90 or more languages
vodniciarv

vodniciarv posted a new bug report

nuxt-i18n •

bug Long time for loading when use 90 or more languages

Version

v5.8.5

Reproduction link

[Not really needed](Not really needed)

Steps to reproduce

  1. Create an app.
  2. Add 10-20 routes.
  3. Add 100 languages.

What is expected ?

Spped!

What is actually happening?

Slow loading app.

Additional comments?

What options (settings) is recoomend to use when in app is 92 languages?
Due to the fact that a huge number of routes (routes) are generated, each page is loaded for a very long time.

Can I somehow solve this problem?

For example, to make so that the routes are not automatically generated for each language …
Thank you in advance.

vodniciarv

vodniciarv posted a new question

nuxt-i18n •

Long time for loading when use 90 or more languages

What options (settings) is recoomend to use when in app is 92 languages?
Due to the fact that a huge number of routes (routes) are generated, each page is loaded for a very long time.

Can I somehow solve this problem?

For example, to make so that the routes are not automatically generated for each language …
Thank you in advance.

orblazer

orblazer posted a new bug report

nuxt-i18n •

bug Route is break when nuxt.config is updated

Version

v5.8.5

Reproduction link

Not really needed

Steps to reproduce

  1. Install nuxt-i18n
  2. Create routes with like config :
[
  'nuxt-i18n',
  {
  locales: [
    { code: 'en', name: 'English', iso: 'en-US', file: 'en.js' },
    { code: 'fr', name: 'Français', iso: 'fr-FR', file: 'fr.js' }
  ],
  defaultLocale: 'en',
  lazy: true,
  langDir: 'locale/',
  vueI18n: {
  fallbackLocale: 'en',
  dateTimeFormats: {
    fr: {
      long: {
        year: 'numeric',
        month: 'long',
        day: 'numeric',
        weekday: 'long'
      },
      timeShort: {
        year: 'numeric',
        month: 'numeric',
        day: 'numeric',
        hour: 'numeric',
        minute: 'numeric'
      },
      timeLong: {
        year: 'numeric',
        month: 'long',
        day: 'numeric',
        weekday: 'long',
        hour: 'numeric',
        minute: 'numeric'
      }
    },
    en: {
      long: {
        year: 'numeric',
        month: 'long',
        day: 'numeric',
        weekday: 'long'
      },
      timeShort: {
        year: 'numeric',
        month: 'numeric',
        day: 'numeric',
        hour: 'numeric',
        minute: 'numeric'
      },
      timeLong: {
        year: 'numeric',
        month: 'long',
        day: 'numeric',
        weekday: 'long',
        hour: 'numeric',
        minute: 'numeric'
      }
    }
  },
  detectBrowserLanguage: {
    useCookie: true,
    alwaysRedirect: true,
    fallbackLocale: 'en'
  },
  onLanguageSwitched: (previous, current) => {
    if (process.client) {
      cookie.serialize('i18n_redirected', current, {
        expires: new Date(new Date() + 365),
        path: '/'
      })
    }
  }
]
  1. Update nuxt.config.js

What is expected ?

Just update

What is actually happening?

When nuxt.config.js is updated we have

 WARN  [vue-router] Route with name 'index___en' does not exist                                                               11:26:56
 WARN  [vue-router] Route with name 'index___fr' does not exist                                                               11:26:56
orblazer

orblazer posted a new bug report

nuxt-i18n •

bug Not apply detectBrowserLanguage when use redirect in other middleware

Version

V5.8.5

Reproduction link

Not really needed

Steps to reproduce

  1. Create middleware like that :
export default function ({ app, redirect }) {
  const hasToken = !!app.$apolloHelpers.getToken()

  if (!hasToken) {
    redirect('login')
  }
}
  1. Enable detectBrowserLanguage. I use :
detectBrowserLanguage: {
  useCookie: true,
  alwaysRedirect: true,
  fallbackLocale: 'en'
}
  1. Try to go http://localhost:3000/

What is expected ?

When use middleware auth and i am not logged need redirect / to /fr/login

What is actually happening?

When use middleware auth and i am not logged i am redirect / to /login

Akhail

Akhail posted a new question

nuxt-i18n •

I can't setup nuxt-i18n

image
image

I follow the official guide but it didn't work, nuxt-i18n has not been injected correctly in the vue instance, it throws me that _vm.$t and this.$i18n does not exists

tasiek

tasiek posted a new feature request

nuxt-i18n •

idea Lazy loading for locales list

What problem does this feature solve?

In some cases, there's a need for a dynamic locales list (i.e. localizations created by editor on CMS). Currently, locales only allows a static array.

What does the proposed changes look like?

To allow dynamic locales listing, locales should allow functions as well, including those returning a Promise.

rchl

rchl posted a new feature request

nuxt-i18n •

idea Add all exposed types/objects to typescript definitions

What problem does this feature solve?

Typescript definitions define $i18n object on vue/types/vue module [1].

Problem 1:
The definitions for $i18n object don't include locale property that nuxt-i18n exposes [2]

Problem 2:
nuxt-i18n actually creates [3] the i18n object, not $i18n. The $i18n is the instance created by vue-i18n plugin itself and it doesn't match the one that nuxt creates. So it doesn't have all the properties and methods that nuxt-18n creates.
So:
A) the i18n property should be added to types on vue/types/vue module.
B) Should investigate not creating two instances of vue-18n (one programatically and one with Vue.use()) and instead set same object to both properties.

[1] https://github.com/nuxt-community/nuxt-i18n/blob/master/types/vue.d.ts#L87
[2] https://github.com/nuxt-community/nuxt-i18n/blob/master/src/plugins/main.js#L86
[3] https://github.com/nuxt-community/nuxt-i18n/blob/master/src/plugins/main.js#L52

What does the proposed changes look like?

Problem 1:
Add

interface VueI18nInterface {
   ...
   locale: string
}

`

victor192

victor192 posted a new bug report

nuxt-i18n •

bug Locale files are loaded into the rendered html code

Version

v5.8.5

Reproduction link

https://www.example.org

Steps to reproduce

  1. npm run build
  2. npm run start
  3. Open source code of the page

What is expected ?

That the locale files will be located in a separate js file and not in the page code

What is actually happening?

Locale files are added in the <script > tag in the html code on each page.

Additional comments?

I use lazy: true in module options.

nathakits

nathakits posted a new feature request

nuxt-i18n •

idea Use different web font when switching language

What problem does this feature solve?

This problem allows for the user to use different types of webfonts suited for different languages. From a design standpoint this is very helpful and essential in showing many webfonts in a website.

What does the proposed changes look like?

A website that has different webfont for different language.

Cjumelin

Cjumelin posted a new feature request

nuxt-i18n •

idea beforeSwitchLanguageAndFirstRender()

What problem does this feature solve?

This will solve a probleme i encounter with internationalization of my app:

When I switch the language or directly load the language (from the url or the localeStorage of the client) I need to switch vuetify.rtl in some case.
On language where RTL is true (i use beforeSwitchLanguage or router.beforeEach call back to set RTL), the RTL value isn't even true on refresh.

What does the proposed changes look like?

It will call the beforeSwitchLanguageAndFirstRender() to set rtl value.

sindael

sindael posted a new feature request

nuxt-i18n •

idea Add ability to alter status code with rootRedirect option.

What problem does this feature solve?

By default, the redirect function sets the HTTP response code to 302 Found. However, there are situations when it is desirable to set a different status. Specifically, this change avoids the issue with google crawlers which mark the root page and the target page of the rootRedirect property as duplicates. This occurs because the crawler expects one of the pages to marked as canonical. In case when the situation is solved with a redirect, the crawler expects status code 301. This simple change improves the website SEO when using rootRedirect.

What does the proposed changes look like?

I attach the updated code and a provided example in the documentation here.