Closed maxmckenzie closed 6 years ago
ah i see your bot closes the ticket if i dont open it somewhere else.
even when you use the correct ISO code there is still the error.
}).filter(item => !!item);
// og:locale meta
const meta = [
// Replace dash with underscore as defined in spec: language_TERRITORY
{ hid: 'og:locale', name: 'og:locale', property: 'og:locale', content: currentLocaleData[LOCALE_ISO_KEY].replace(/-/g, '_') }, ...this.$i18n.locales.filter(l => l[LOCALE_ISO_KEY] !== currentLocaleData[LOCALE_ISO_KEY]).map(locale => ({
hid: 'og:locale:alternate-' + locale[LOCALE_ISO_KEY],
name: 'og:locale:alternate',
property: 'og:locale:alternate',
content: locale[LOCALE_ISO_KEY].replace(/-/g, '_')
}))];
Hi @maxmckenzie What does your config look lilke?
Hey @paulgv thanks so much for the reply, unfortunately, I'm working on a time-sensitive project. So I've now gone with just using vue and rolling my own boilerplate. As such i've removed the config and i didnt commit a version of it so its not in my git history.
If i get some time spare i shall try to replicate the issue.
@paulgv I am getting the same error and I am using the config straight out of the docs:
['nuxt-i18n', {
locales: ['en', 'fr', 'es'],
defaultLocale: 'en',
vueI18n: {
fallbackLocale: 'en',
messages: {
en: {
welcome: 'Welcome'
},
fr: {
welcome: 'Bienvenue'
},
es: {
welcome: 'Bienvenido'
}
}
}
}]
@paulgv here you can find a project with this error: https://github.com/mahnuh/nuxt-test
Thanks @mahnuh ! There were some checks missing in the SEO plugin, the issue should be fixed in v3.2.2 :smiley:
[edit]
By the way, if you're not using SEO features, I'd recommend you set the seo
option to false
in your config so the module won't try to generate the meta.
Thanks @paulgv , you just made my day - again! 😃
@paulgv I have the same issue, but only on 404 page, Nuxt-i18n version is 4.0.0, my config:
modules: [
['nuxt-i18n', {
locales: [
{
code: 'ru',
iso: 'ru',
},
{
code: 'en',
iso: 'en',
},
],
strategy: 'prefix',
rootRedirect: 'ru/1',
vueI18n: {
fallbackLocale: 'ru',
messages: {
ru: {
welcome: 'Welcome'
},
en: {
welcome: 'Bienvenue'
},
}
},
}]
]
This bug-report has been fixed by @paulgv in release v3.2.2.
I am facing the same issue with the current Nuxt version (2.1.0)
@begueradj You probably missed to encapsulate the module in an array. You can find more details on the issue here: https://github.com/nuxt-community/google-adsense-module/issues/13#issuecomment-397820366
@gnuletik @paulgv I'm still getting this error with nuxtjs v2.4.3 and nuxt-i18n v5.8.4
Instead of redirecting or giving a proper 404 when i hit any older page (aka /careers
which is now /en/careers
) I get "Cannot read property 'iso' of undefined"
['nuxt-i18n', {
locales: [
{
code: 'en',
iso: 'en-US',
},
{
code: 'jp',
iso: 'ja',
},
],
deafultLocale: 'en',
rootRedirect: 'en',
vueI18n: { fallbackLocale: 'en', },
}]
I've looked a bit at the code.
With default strategy (prefix_except_default
), with two pages: index.vue
and about.vue
, these routes are generated:
routes: [{
path: "/en/about",
component: _33ee994b,
name: "about___en"
}, {
path: "/jp/about",
component: _33ee994b,
name: "about___jp"
}, {
path: "/en/",
component: _53a67410,
name: "index___en"
}, {
path: "/jp/",
component: _53a67410,
name: "index___jp"
}],
As there is no /about
route being generated, the whole redirection logic fails because it can only redirect from existing routes due to needing route's name to properly resolve current route and route to redirect to.
The behavior is slightly different whether it's first redirect in the app or subsequent. On first it will redirect from unknown route to index
. After that, when cookie is already set, it will just fail with error above (unless alwaysRedirect: true
I guess).
It's IMO also buggy that on first redirect it will redirect to index. It should probably just trigger 404 if it can't figure out which route to redirect to.
One way to fix it would potentially be to add code to resolve route by path. If user visits non-existing route like /about
, we would add defaultLocale prefix and try to resolve by path. But then when user visits /xx/about
, maybe we should strip the 'xx' prefix and then add default locale. Not sure how smart it would need to be.
BTW. The root issue seems to stem from bad redirection logic but it would be easy to foolproof the code that is failing (in seo-head.js) to not fail in this case.
Created PR #233 that will fix the crash but won't fix/change redirection logic.
^ I am not handing this site a token for my github account.
i'm getting the error
Cannot read property 'iso' of undefined
i'd like to know which iso you are using there is
es
of the iso andes-ES
soooooo which is it.