i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Warnings in console after ignore route in-component

Open Jassmin586 opened this issue 4 years ago • 12 comments

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

image

How properly can I set one language for page without warnings?

Jassmin586 avatar May 15 '20 09:05 Jassmin586

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.

rchl avatar May 15 '20 10:05 rchl

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.

image

Jassmin586 avatar May 15 '20 15:05 Jassmin586

Could be also coming from seo functionality if you have that enabled. But I will look into it later (can't right now).

rchl avatar May 15 '20 17:05 rchl

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 avatar May 21 '20 21:05 rchl

@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.

matsrietdijk avatar Jun 12 '20 11:06 matsrietdijk

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.

ozgurdemir avatar Jun 17 '20 15:06 ozgurdemir

The same issue.

Menark avatar Jul 01 '20 12:07 Menark

Looking for clear solution on this matter. I am getting similar warnings

quangnhattran avatar Jul 06 '20 15:07 quangnhattran

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.

stale[bot] avatar Sep 04 '20 20:09 stale[bot]

Any updates?

HADB avatar Oct 29 '21 08:10 HADB

Any updates?

gouz7514 avatar Sep 14 '22 10:09 gouz7514