Fix unreliable article language and write it onto the reader view page
Categories
(Firefox for Android :: Contextual AI, task, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox156 | --- | fixed |
People
(Reporter: bclark, Assigned: moyin)
References
Details
(Whiteboard: [fxdroid][android-core])
Attachments
(1 file)
ReaderView.show() reads the article language with result.language = doc.documentElement.lang. doc can be either a real DOM or a JSDOMParser DOM. JSDOMParser only defines getters for className, id, href, src and srcset - it has NO getter for lang, only getAttribute. The two sources race and the winning value changes between runs, so the language is not reliable today.
Separately, the rendered reader page never has the language written onto it, so downstream consumers (including PageExtractor.getPageMetadata()) cannot read it. Text-to-speech needs a correct locale or it pronounces the article wrong.
TECHNICAL NOTES
- File: mobile/android/android-components/components/feature/readerview/src/main/assets/extensions/readerview/readerview.js
- Current line 50: result.language = doc.documentElement.lang;
- Change to: result.language = doc.documentElement.getAttribute("lang") || "";
- Add after
document.title = result.title;: document.documentElement.lang = result.language; - Both changes are in the same show() function and ship as one patch
- Note result.language also feeds getReadingTime() and getTextDirection(), so this fix changes existing behaviour for RTL detection and reading-time estimates - verify no regressions there
ACCEPTANCE CRITERIA
- result.language returns the correct tag for both the real-DOM and JSDOMParser code paths
- The rendered reader page carries <html lang="..."> matching the source article
- getPageMetadata().language returns the article language for a moz-extension: reader page
- Unit tests cover both DOM paths, including an article with no lang attribute (expect "")
- No regression in reading-time or RTL text-direction behaviour
Part of the Listen to Page text extraction epic (FXDROID-9830).
Updated•1 month ago
|
| Assignee | ||
Updated•1 month ago
|
| Assignee | ||
Updated•1 month ago
|
| Assignee | ||
Comment 1•1 month ago
|
||
Moving to the Contextual AI component. All Listen to a Page work belongs there rather than in Reader Mode or Experimentation and Telemetry: Contextual AI is triaged by the Core Team, and Listen sits with the other AI features in the team's ownership model. Epic 2 (bug 2064821, FXDROID-9925) was filed into Contextual AI from the start; this brings epic 1 into line. No other field is changed.
Comment 4•1 month ago
|
||
| bugherder | ||
Description
•