Page MenuHomePhabricator

Fix inconsistency in Table of Contents localization
Open, Needs TriagePublic

Description

In Parsoid, the table of contents is localized (and language-converted) during post processing. The SectionMetadata of the canonical Parsoid output has ascii digits and un-language-converted text.

In the legacy parser, the table of contents has digits localized immediately upon creation, and the language conversion is done on the contents just before the Parser exists. So effectively, the SectionMetadata is always fully localized.

Special pages use the legacy parser convention as well (fully localized SectionMetadata).

It would be more convenient, especially as the legacy parser is deprecated, to move toward the Parsoid convention of localizing the table of contents during post processing, or at least marking the SectionMetadata in some way to indicate whether or not localization has been performed.

This is complicated somewhat by the fact that language converter state is stored implicitly and globally: we need to language-convert the text in the legacy parser immediately after parsing the main article body in order to (re)use the implicit global language converter state, in particular any article specific rules that apply to section titles. Parsoid parses language converter rules but does not evaluate them until postprocessing, so in order to appropriately use the implicit global language converter state it needs to localize the TOC at this time as well. Special pages generally use MW interface messages for table of contents section labels, which are generated specifically for a given variant and do not need to be language-converted. Special pages *do* need to localize the numbers in the section labels however.