i18n
i18n copied to clipboard
Warnings in console after ignore route in-component
My app have got two languages (en and ar). To set only one language in specific page I used 'in-component' option:
nuxtI18n: {
locales: ['en']
},
After that I have a page with only en language, that's great but also a lot of warnings in console like
How properly can I set one language for page without warnings?
This is probably triggered because you have language selector somewhere on the page that calls localePath
or switchLocale
with those other locales.
You'd need to show the code that triggers those warnings, then I might be able to advise more.
I commented all localePath
and switchLocale
in project and still the same.
Simple reproduce: https://codesandbox.io/s/710-nuxt-i18n-vqgsx?file=/pages/about.vue
Turn to Console and click 'About' link on homepage.
Could be also coming from seo
functionality if you have that enabled.
But I will look into it later (can't right now).
Yes, those are triggered from seo functionality (seo: true
).
I'll check later if I can do something about it.
For the record: the issue is due to disabling some locales per-route. In that case we don't keep track of which page has which locales disabled and so we assume that all locales are available.
@rchl this warning it triggered even more when seo: true
, thats true. But the real issue is loadAndSetLocale
which doesn't consider either filtering locale on the component as @Jassmin586 did above or the possiblilty of setting nuxtI18n: false
on the component.
So even when disabling seo all together this warning will still be thrown on initial load and any time you programatically switch the locale with $i18n.setLocale(..)
on a page configured like this.
Any updates on this? I'm running into the same issue. Probably related to this but I'd also like to remove the language switcher on pages which don't have that language enabled. It seems i18n does not have any variable stating which languages are actually available for the actual page.
The same issue.
Looking for clear solution on this matter. I am getting similar warnings
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Any updates?
Any updates?