-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set html lang attribute from language setting #5685
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -382,6 +382,7 @@ async function loadLanguage() { | |
} | ||
try { | ||
await languageHandler.setLanguage(langs); | ||
document.getElementById("root").setAttribute("lang", languageHandler.getCurrentLanguage()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should propably be done in matrix-react-sdk inside the languageHandler.js. Otherwise it doesn't get changed if the user changes the language in the settings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is true, and then even more evidently you can't rely on the outermost html element having an id since riot isn't the only consumer of matrix-react-sdk There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You actually want document.documentElement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MTRNord Are you sure? Doesn't the entire page get reloaded when you change language, and, thus, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pafcu well the current would propably need a refactor as soon as the translation change uses states instead a full reload There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MTRNord And the "put it into the sdk" would need a refactor as soon as the split between the sdk and riot-web is made more clear. Perhaps the correct approach is to fire a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pafcu what about putting this (in another PR) inside a promise returned from setLanguage()? That would propably make more sense to do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does that solve the issue of an app-developer only wanting to change the language of the matrix-specifc part of their page, rather than the entire page? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pafcu no but the issue that a reload might not happen in the future on language changes. (Thats what my point is) |
||
} catch (e) { | ||
console.error("Unable to set language", e); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why adding a redundant id instead of using
document.getElementsByTagName
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason other than I thought that might be more explicit. I wasn't sure which would be more ideal. I can go ahead and change this to use
document.getElementsByTagName
instead if that is preferred.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a chance that
home.html
, when opened, contains extrahtml
tags. To prevent conflicts, assigning an id is probably best. Although I'd prefix it to avoid more conflicts (egmx_PageRoot
).