Page MenuHomePhabricator

Invalid language code handling in LanguageConverter markup in VisualEditor
Closed, ResolvedPublic

Description

Handling of invalid language codes in LanguageConverter markup in VisualEditor appears to have regressed slightly.

Originally for an invalid language code the message visualeditor-mwlanguagevariantcontextitem-rule-invalid-language-label would be displayed in the left hand column below:

image(8).png (281×424 px, 36 KB)

In 2020 @Esanders made a change to getLanguageName to return the language code it was provided if there's no name found. At the moment, then, the only way "invalid-language-label" shows up is if there's an empty language code (which the parser would probably reject). The original intent was to display "<Invalid> xx" in the case above, to make it less confusing if the original wikitext was something like -{English: Foo}- which right now shows up as "English English" with no particular indication that the markup is bogus.

In https://gerrit.wikimedia.org/r/c/mediawiki/extensions/VisualEditor/+/1015033 we changed the message to <em>Invalid</em> which would help visually distinguish this from a valid code; this task is for fixing the check for if the language key exists. Currently we use $.uls.data.getAutonym which returns the code if the name is not found.

Event Timeline

Change #1015028 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/VisualEditor@master] Fix displaying of "<Invalid>" when an language code isn't found

https://gerrit.wikimedia.org/r/1015028

Change #1015028 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Fix displaying of "<Invalid>" when an language code isn't found

https://gerrit.wikimedia.org/r/1015028