Background
See T341244: ParserOptions and Title::getPageViewLanguage may disagree on the lang/dir. In a nut shell, it is (unfortunately) common today for extensions to try to "guess" the language and directionality of embedded content. The reason for this is largely that a better API didn't exist, and classes like mw-content-ltr are important to set for correct styling, and are difficult to set by any means other than Title::getPageViewLanguage. But, Title::getPageViewLanguage involves global state and a lot of guess work.
Scope
https://codesearch.wmcloud.org/deployed/?q=%3EgetPageViewLanguage
Title::getPageViewLanguage
- EventLogging (MetricsPlatform/ContextAttributesFactory.php). Data-Engineering
- TemplateSandbox (Hook, SpecialPage). Unassigned: No owner.
- DiscussionTools (SpecialDiscussionToolsDebug.php). Editing-team
- Scribunto (ScribuntoContentHandler.php). Unassigned: No owner.
- Flow
ContentHandler::getPageViewLanguage
Outcome
Remove use of Title::getPageViewLanguage.
Example migration:
- HTML workarounds: In cases where it is used to manually create CSS classes like mw-content-ltr and mw-parser-output, and the lang and dir attributes, this can probably removed given that nowadays ParserOutput will take care of setting these already. Be sure to test the end-user workflow and confirm that your workarounds are redundant before removing them. When not possible to remove or if not feasible in the short-term, at least use ParserOutput->getLanguage() to inform your current workarounds instead of the global guesswork from Title::getPageViewLanguage.
- Language code. If using Title::getPageViewLanguage to associate page language outside a pageview perspective, it is likely incorrect. Consider using Title->getPageLanguage() instead.