Listen for when the document's html lang attribute is changed
Categories
(Firefox :: Translations, defect, P3)
Tracking
()
People
(Reporter: epavlov, Unassigned)
Details
Steps to reproduce:
- Go to German Wikipedia https://de.wikipedia.org/wiki/Wikipedia:Hauptseite
- Enable automatic translation from German to English in the popup menu
- Go to DW in German (choose the language in the hamburger menu if needed) https://www.dw.com/de/themen/s-9077
- Navigate to any page
Expected:
- The page was translated right after switching the language
- The pages are translated while browsing the website
Actual:
- I have to reload the web pages to translate automatically
Comment 1•1 year ago
|
||
I can't reproduce myself, when I navigate to https://www.dw.com/de/themen/s-9077 it is automatically translated.
Comment 2•1 year ago
•
|
||
This is a case where the language is changed by JavaScript. We should probably come up with a better strategy to handle when a page changes the language tag.
Here is the page source:
<!doctype html>
<html lang="en">
<head>
...
<script type="module" crossorigin src="/static/index-82437323.js"></script>
<link rel="stylesheet" href="/static/index-ef709cb8.css">
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
</body>
</html>
While the live page with JS is:
<html lang="de" data-rh="lang">
The TranslationsChild checks this at DOMContentLoaded
, although maybe we should wait a micro-tick to allow a page to win the race of who's DOMContentLoaded fires first.
handleEvent(event) {
switch (event.type) {
case "DOMContentLoaded":
this.innerWindowId =
this.contentWindow?.windowGlobalChild.innerWindowId;
this.sendAsyncMessage("Translations:ReportLangTags", {
documentElementLang: this.document.documentElement.lang,
});
break;
}
}
To further complicate things, in Bug 1840857 I am moving this code to C++, which is may be trickier to find a good hook for when things change.
What's even worse here is that we may automatically translate FROM English for someone, which will be another "Language Degradation Machine".
Comment 3•1 year ago
|
||
I can't reproduce myself
It's a race condition and is only intermittently reproduceable.
Comment 5•1 year ago
|
||
The severity field is not set for this bug.
:nordzilla, could you have a look please?
For more information, please visit BugBot documentation.
Updated•1 year ago
|
Updated•1 year ago
|
Comment 6•1 year ago
|
||
I changed this bug to be about listening for the lang
tag changing. I'm not 100% sure what we should do for cases like this, as it could lead to a situation where we offer an English translation, and then offer a German one.
Description
•