The HTML lang attribute does not change.
Unanswered
Somali posted this in #help-forum
SomaliOP
The documentation states: https://nextjs.org/docs/pages/building-your-application/routing/internationalization#search-engine-optimization
"The lang attribute is added to HTML automatically" .
But when I switch the language using next/link, my lang attribute doesn't change.
I can use useRouter and locales to change this myself, but why does the Next.js documentation mention it?
I use next 13 without app router
I change locales like this (screenshot):
"The lang attribute is added to HTML automatically" .
But when I switch the language using next/link, my lang attribute doesn't change.
I can use useRouter and locales to change this myself, but why does the Next.js documentation mention it?
I use next 13 without app router
I change locales like this (screenshot):
24 Replies
SomaliOP
anyone?
@Somali The documentation states: https://nextjs.org/docs/pages/building-your-application/routing/internationalization#search-engine-optimization
"The lang attribute is added to HTML automatically" .
But when I switch the language using next/link, my lang attribute doesn't change.
I can use useRouter and locales to change this myself, but why does the Next.js documentation mention it?
I use next 13 without app router
I change locales like this (screenshot):
i can't test right now, but this smells like a bug... can you make a minimal reproduction repository?
@joulev i can't test right now, but this smells like a bug... can you make a minimal reproduction repository?
SomaliOP
It is important to clarify that this is already happening on my 3rd project, as if I am doing something wrong. BUT I think it's very difficult to DO SOMETHING WRONG
Interesting, I’ll have a look
Sorry for being late, I almost forgot about this
(in dev mode, but should work fine in prod mode as well)
@joulev <@236135464078278656> finally have time to check, but i see it working normally though
SomaliOP
what. i just checked this again and now all working correct. on all my projects.
i realy cant understand this.
thank you for checking that!
i realy cant understand this.
thank you for checking that!
since <Link> uses router methods behind the scenes, if router.push works <Link> should work as well, so I was quite confused how one worked and the other didn't
glad it works for you now
@joulev since <Link> uses router methods behind the scenes, if router.push works <Link> should work as well, so I was quite confused how one worked and the other didn't
SomaliOP
hi, again
Perhaps at that moment I confused the essence of the problem 😄
Perhaps I mean that if I initially go to site.com/de , then in the html tag I will still have en (Since this is the default locale)
Perhaps at that moment I confused the essence of the problem 😄
Perhaps I mean that if I initially go to site.com/de , then in the html tag I will still have en (Since this is the default locale)
@Somali hi, again
Perhaps at that moment I confused the essence of the problem 😄
Perhaps I mean that if I initially go to site.com/de , then in the html tag I will still have en (Since this is the default locale)
So as in regardless of where you go after you have visited the website, the lang attribute remains the same?
I don’t understand, please clarify
@joulev I don’t understand, please clarify
SomaliOP
go to https://gmp-media-group.com/de
and look at lang attr in html
and look at lang attr in html
@joulev I don’t understand, please clarify
SomaliOP
it will be 'en' but we go on 'de' version
@Somali go to https://gmp-media-group.com/de
and look at lang attr in html
that's weird, in my app using i18n this doesn't happen
can you give me a minimal reproduction?
@joulev that's weird, in my app using i18n this doesn't happen
SomaliOP
send in pm
@joulev that's weird, in my app using i18n this doesn't happen
SomaliOP
or you need more minimal example?
@joulev well you forced lang=en here
SomaliOP
oh, okay, thank you a lot, sir