Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When changing languages dynamically should the HTML lang attribute be updated?

I have a single-page website that loads an AngularJS application that supports different languages.

All the views for the website are rendered in the browser via JavaScript after the HTML has been loaded from the server.

I understand the value of setting a correct language attribute for <html lang="en"> when Google indexes the static pages.

I am wondering if I need to update this language attribute when AngularJS dynamically changes languages. For example; The user can select from a dropdown which language the interface is shown as.

When the language changes there is no re-loading from the server. So the last setting <html lang="en"> will persist.

Is there any reason that I should update this attribute dynamically when the language changes?

EDIT: This is not a question about google or web crawlers. I'm wondering if this attribute is used by the web browser in anyway.

like image 859
Reactgular Avatar asked Oct 31 '22 10:10

Reactgular


1 Answers

Yes. Screen readers use this attribute. But you also have to test that screen readers would consider correctly a dynamic change in this attribute.

like image 98
Adam Avatar answered Nov 10 '22 17:11

Adam