Page MenuHomePhabricator

Page Content Service does not show Simplified and Traditional Chinese translations
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • On either Wikipedia Android or iOS app, open a random article in one of the Chinese languages

What happens?:
The "about this article", "Content is available under CC BY-SA 4.0 unless otherwise noted", etc. are in English.

What should have happened instead?:
It should be in Chinese (Simplified or Traditional correspondingly).

Other information (browser name/version, screenshots, etc.):
Relevant messages are all translated on twn.net.

Event Timeline

It looks like the cause is the following:

The language code of the article contents is formatted in the BCP 47 style (capitalized zh-Hans):
<meta property="pcs:locale" content="zh-Hans">

However, the endpoint that returns the translatable messages uses the original non-BCP-47 language code (lowercase zh-hans):

{
  locale: "zh",
  messages: {
    zh-hans: {
      description-add-link-title: "添加条目描述",
      article-read-more-title: "阅读更多",

the original non-BCP-47 language code (lowercase zh-hans)

BCP 47 is case-insensitive, so zh-hans is by definition the same BCP 47 code as zh-Hans. See https://www.rfc-editor.org/rfc/rfc5646.html#section-2.1.1 which says:

At all times, language tags and their subtags, including private use
and extensions, are to be treated as case insensitive: there exist
conventions for the capitalization of some of the subtags, but these
MUST NOT be taken to carry meaning.

the original non-BCP-47 language code (lowercase zh-hans)

BCP 47 is case-insensitive, so zh-hans is by definition the same BCP 47 code as zh-Hans. See https://www.rfc-editor.org/rfc/rfc5646.html#section-2.1.1 which says:

At all times, language tags and their subtags, including private use
and extensions, are to be treated as case insensitive: there exist
conventions for the capitalization of some of the subtags, but these
MUST NOT be taken to carry meaning.

More precisely, it looks like the Banana-i18n library is being (incorrectly?) case-sensitive about the language code.

https://github.com/wikimedia/banana-i18n/blob/master/src/messagestore.js#L50

It works when initialized with the lowercase zh-hans locale, but fails (falls back to English) when initialized with zh-Hans.

https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/services/mobileapps/+/refs/heads/master/pagelib/src/pcs/c1/Footer.js#184