Vue-i18n: Updating the html tags lang attribute automatically

Created on 21 Oct 2018  路  4Comments  路  Source: kazupon/vue-i18n

I think it would be a good idea to automatically update the lang attribute of the HTML tag when the i18n.locale variable is changed.
It isn't hard to implement it yourself but I think a lot of people forget it or don't even know about it so changing it automatically by default would be helpful.
It's as simple as document.getElementsByTagName("html")[0].lang = newLanguage;.
Is there a reason this shouldn't be implemented?

More information on w3.org:
Why use the language attribute

Most helpful comment

I agree that it is pretty easy to change it yourself.
I just meant that people often probably don't even think about it.
But i18n.locale not having the same standard as html lang is definitely a problem.

All 4 comments

I believe it's easy to update lang attribute with a watcher.
I did it with different ways, e.g html-webpack-plugin, vuex store watch...
And also I have a repo of a docs-site, which support different languages in docs only,
even that my site itself is in English.

And,
html lang should be standard in BCP 47 - Tags for Identifying Language #. i18n.locale can any value if you like.

Sooo, I don't think it's a good idea for vue-i18n itself.

I agree that it is pretty easy to change it yourself.
I just meant that people often probably don't even think about it.
But i18n.locale not having the same standard as html lang is definitely a problem.

html lang should be changed with userland.

html lang should be changed with userland.

@kazupon Can you be a bit more specific on how to achieve that?

Was this page helpful?
0 / 5 - 0 ratings