Steps to replicate the issue (include links if applicable):
- Go to Mandarin Wikipedia and click “View Source” or “Edit” on any random page.
- Inspect #wpTextbox1
What happens?:
The lang attribute is set to zh regardless of language variant settings.
On pages with <html lang="zh-Hant-TW">, this redundant <textarea lang="zh"> attribute would override CJK rendering on wikitext editors and break punctuation renderings.
What should have happened instead?:
It should follow page variant or user settings.
Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
1.43.0-wmf.7 (b6ef248)
Other information (browser name/version, screenshots, etc.):
The current wikitext editor declares unnecessary lang HTML attribute on its internal source editor. For example, on MediaWiki, it’s en regardless of your language setting; on Mandarin Wikipedia, it’s zh regardless of your variant setting.
This seemingly harmless redundancy actually breaks editing experience the Mandarin Wikipedia – CJK fonts require proper lang attribute to determine which set of characters and punctuation rules to apply, which is why Mandarin Wikipedia has a very delicate system on distinguishing and converting, say, zh-Hans-MY, zh-Hant-HK and zh-Hant-TW. (Adobe explained this difference very clearly in the README file of Source Han Sans.)
Upon further inspection, it seems that MediaWiki\EditPage\TextBoxBuilder is the cause of this problem. The current behavior overrides the root <html lang> setting and makes the editor a pain to read. It should either copy the attribute from root <html> element or just remove this redundancy altogether.