Page MenuHomePhabricator

"View edit history" menu item in the mobile-html footer shows incorrect edit status in zhwiki
Open, In Progress, MediumPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

What happens?:
The edit status is showing incorrectly.

It will show "今日更新" (Updated today) correctly if the edit was made today.

But, if the edit was not made today, it will always show "昨日更新" (Updated yesterday).

What should have happened instead?:
Should show the correct status in Chinese.

Event Timeline

If not easy to give contextual dates ("3 months ago"), better to just give absolute dates ("Dec 20 2022") in Chinese.

A similar issue was mentioned here: T249541. After additional research, I've found that View edit history functionality had not been implemented at all. Check PCS here - https://github.com/wikimedia/mobileapps/blob/master/pagelib/src/pcs/c1/DemoMode.js#L23. The value of editedDaysAgo is hardcoded and was intended to be replaced by upcoming (?) functionality. I checked example of the summary endpoint of one of the article, but it seems that there is no explicit property editedDaysAgo there. However, I can calculate it inside PCS using the timestamp property and then render it on the footer.
@MSantos, @Jgiannelos , what do you think?

Change 804558 had a related patch set uploaded (by Vadim Kovalenko; author: Vadim Kovalenko):

[mediawiki/services/mobileapps@master] "View edit history" menu item in the mobile-html footer shows incorrect edit status in zhwiki

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

I've implemented View edit history functionality and added i18n tests for Arabic. As for zh languages, they won't work properly till zh-hans and zh-hant (along with some others) be introduced in the banana-i18n package (full list of supported languages here). @Nikerabbit , what do you think? You've mentioned zh and mk languages in https://phabricator.wikimedia.org/T249541#7569365 but mobileapps has 134 predefined language variants compared with banana-i18n which has only ~12 corresponding langs and some fallbacks.

cc: @MSantos , @Jgiannelos

@vadim-kovalenko Please give more details than "won't work properly" about what is the problem.

https://github.com/wikimedia/banana-i18n/tree/master/src/languages is a list of languages that have additional handling for {{PLURAL}}. It is not a list of supported languages. The library does not have a clear list of supported languages: it uses information from different sources and relies e.g. on browser's Intl methods to handle plural forms.

@cooltey Just a clarification regarding the API.
When calling footer=true on the API endpoint the output is a demo page with a hardcoded value, but not what the apps consume. I think its worth fixing it too to display the right last edit timestamp but for the actual scope of the problem on the apps level what needs to be fixed is the way we render the last edit timestamp to string for the specific locale.

cc @vadim-kovalenko ^

Got it, thanks for the clarification! @Jgiannelos

Hi @Nikerabbit , thank you for the additional info about the banana-i18n library. I will provide more details. Please, install banana-i18n in isolated environment and check this code snippet for zh-hant:

const Banana = require('banana-i18n')
const banana = new Banana('lzh')

const chineseMessage = "{{PLURAL:$1|昨日更新|$1 日前更新|0=今日更新}}" // zh-hant message taken from https://github.com/wikimedia/mobileapps/blob/master/i18n/zh-hant.json#L19

console.log('today ', banana.i18n(chineseMessage, 0));
console.log('yesterday: ', banana.i18n(chineseMessage, 1));
console.log('two days ago ', banana.i18n(chineseMessage, 2));

Output for zh-hant correct:

today  今日更新
yesterday:  昨日更新
two days ago  2 日前更新

For zh-hans update chineseMessage variable to {{PLURAL:$1|更新于昨天|更新于$1天前|0=更新于今天}} taken from here and rerun script:

Output is also correct:

today  更新于今天
yesterday:  更新于昨天
two days ago  更新于2天前

The problem begins if we set the specific Chinese locales: new Banana('zh-hant') or new Banana('zh-hans'). In that case, 'Yesterday' and 'N days ago' translated the same, and this issue was mentioned in the task description. After a little research, I found that language locale can be intercepted here. Pls, let me know if you need more context for this problem and confirm whether this issue should be fixed on the banana-i18n level.

According to CLDR Chinese only has one plural form, so these messages are actually not correct. See also my comment in (T249541#7569365).

I guess browsers don't support lzh (from your example. lzh is the language code for Classical Chinese which is different from zh) and fallback to English plural rules, which would explain the behavior you see and expect, but which is incorrect.

I repeat my suggestion to use different messages instead of (ab)using the plural syntax what it was not intended for.

@cooltey , I'm going to refactor i18n plural rules for messages for zh-hant here and zh-hans here in mobileapps. Could you suggest the right translation for both variants (zh-hant and zh-hans) when it comes to translating these words: Updated today, Updated yesterday, Updated N days ago ?

Hi @vadim-kovalenko

Regions that use Traditional Chinese

zh-hant
zh-tw
zh-hk
zh-mo

For default zh, you can use this one as well.

today  今日更新
yesterday:  昨日更新
%s days ago  %s 日前更新

Regions that use Simplified Chinese

zh-hans
zh-cn
zh-my
zh-sg

today  更新于今天
yesterday:  更新于昨天
%s days ago  更新于 %s 天前

@cooltey considering @Nikerabbit suggestions of using different messages: can you help us advance with that?

Hi @MSantos

I am not sure I understand it correctly. I would recommend using the following variables with translations.


Regions that use Traditional Chinese

zh-hant
zh-tw
zh-hk
zh-mo

For default zh, you can use this one as well.

page-last-edited-today  今日更新
page-last-edited-yesterday  昨日更新
page-last-edited-days-ago  %s 日前更新

Regions that use Simplified Chinese

zh-hans
zh-cn
zh-my
zh-sg

page-last-edited-today  更新于今天
page-last-edited-yesterday  更新于昨天
page-last-edited-days-ago  更新于 %s 天前