Open jonathanolson opened 2 years ago
@jonathanolson - This is assigned to me, and has been for over a year, but I don't know what I should do about it. Is it assigned to me because I generally take care of Rosetta (the sim translation utility)? If so, how should Rosetta change to support this?
I'm going to unassign myself for now. Feel free to assign this back to me when there is a bit more information about it, or to set up a meeting to discuss.
Doing a search for "Can html lang attribute change after page is loaded", I find this article that suggests changing lang
after the page is loaded could be problematic for screen readers: https://stackoverflow.com/questions/41592689/does-changing-the-html-lang-attribute-after-page-load-have-any-effect
So the general question is… Are there things that read the lang attribute when the page is loaded, and that will not know that lang is changed? And will that cause problems?
Additional notes taken during dev meeting:
SR: Ideally, this would change dynamically based on query parameter + preferences dialog. Does our standard (for what locale codes we use) match the browser standard for locale codes?
According to [this MDN page](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang), lang uses “BCP47” ([this](https://datatracker.ietf.org/doc/html/rfc5646) says that is equivalent to ISO 639)
JB: Is that valid in HTML5 - to change the lang attribute of the document based on the query parameter?
JG: gpt-4o says its common to change it, if we trust that
JG: It’s fine for it to change - can we change this in main and skip the MR?
The dev team thinks this is fine
MK: Let’s add an issue to joist and implement this - changing the locale will update the lang attribute on the html document
CM: Could this affect screen readers?
TS: Screen readers will be on the PDOM, so as long as that is updated we should be ok
CM: So the question is… Are there things that read the lang attribute when the page is loaded, and that will not know that lang is changed. And will that cause problems?
https://github.com/phetsims/chipper/issues/1332#issuecomment-2377637143
SR: https://stackoverflow.com/questions/28459846/when-changing-languages-dynamically-should-the-html-lang-attribute-be-updated
https://stackoverflow.com/questions/35187645/how-to-set-html-lang-attribute-dynamically
TS will make an issue about this in joist, and the sub-team will handle it from here (we have an issue)
Other links:
Adjust HTML language attribute · Issue #1332 · phetsims/chipper (github.com)
SR: Map from our locale codes to the correct standard
See https://github.com/phetsims/chipper/issues/1332
TS: Since the lang attribute can be added anywhere in a page, I have a feeling a dynamic lang attribute is not a problem, but not having a lang attribute is a known problem. We can verify a dynamic language attribute is generally safe and a good practice.
We should be setting the
lang
attribute on the HTML element. Should assess whether this is maintenance-release-worthy. We won't mess with thelang
attribute on the PDOM.Notes from dev meeting: