Page MenuHomePhabricator

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


A file has contracted a case of bad language code upon use of SVG Translate Tool. The revision in question is; it works after being changed to

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 ?

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 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 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