Page MenuHomePhabricator

Bad language code: zh_Hans should be zh-Hans
Open, Needs TriagePublic

Description

A file has contracted a case of bad language code upon use of SVG Translate Tool. The revision in question is https://upload.wikimedia.org/wikipedia/commons/archive/d/dc/20201231085805%21Research_design_and_evidence_-_Capho.svg; it works after being changed to https://upload.wikimedia.org/wikipedia/commons/d/dc/Research_design_and_evidence_-_Capho.svg.

To reproduce, just choose 中文(简体)as the target language. Typing "zh" in the search box helps.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

This seems pretty easy to fix.

EDIT: I did not find any 'Hant' in the repository. I needs some more digging. Maybe was specific to your file ?

This seems pretty easy to fix. Where should we edit the code, github ?

https://github.com/wikimedia/svgtranslate

This tag is far less visible than a column. Tickets wont get done, and new developers won't onboard. This project direly need new, active developers.

@Yug: It is not, as tags are shown on workboards. Having 2000 incompatible, different per-projcet ways that make it impossible to find "easy to pick" tasks across projects does not help, when good first task are mentioned on https://www.mediawiki.org/wiki/New_Developers and other pages.

Received. Thanks for the alternatives.

I noticed that one user made several Kurdish translations in Arabic script that failed to show up. Looking at the SVG, the files had systemLanguage="ku_ARAB" instead of systemLanguage="ku-Arab" (capitalization is not important).

I went to https://svgtranslate.toolforge.org/File:100_Years_War_France_1435.svg and selected default language to ku-Arab (I typed in "ku" and then selected the language in Arabic script), made a test edit, and then downloaded the file. The file used systemLanguage="ku_ARAB" for my test edit.; it should have used ku-Arab.

That suggests SVG Translate is using Unix locale strings instead of IETF langtags. The correct SVG syntax uses a hyphen rather than an underscore.

Please do not be confused by WMF feeding librsvg a langtag through its $LANG environment (locale) variable. That is a hack, and it will bite us in the upgrade to the newer version of librsvg. See T154237, T265549, and T40010.

The code should never be looking for underscores in a systemLanguage attribute.

svgtranslate/src/Model/Svg/SvgFile.php /

/**
 * Reorder text elements within the document so that all sublocales (i.e. systemLanguage values
 * containing a hyphen or underscore, e.g. de_CH) are moved to the beginning of the switch
 * element, and all fallback elements are moved to the end.
 */
protected function reorderTexts(): void