Page MenuHomePhabricator

[M] Empty state message is mangled in Hebrew
Closed, ResolvedPublic

Description

Screen Shot 2020-10-08 at 5.23.39 PM.png (606×624 px, 56 KB)

The message itself looks okay, so we need to figure out why this isn't rendering properly and fix it. As part of this task, we should test in various languages, and review other messages in Hebrew (at least ones with HTML and variables that need to be parsed).

Acceptance criteria:

  • Empty state message renders properly in Hebrew

Event Timeline

CBogen renamed this task from Empty state message is mangled in Hebrew to [M] Empty state message is mangled in Hebrew.Oct 21 2020, 4:26 PM

FWIW the message renders properly in the PHP UI

Change 635898 had a related patch set uploaded (by Anne Tomasevich; owner: Anne Tomasevich):
[mediawiki/extensions/WikibaseMediaInfo@master] Fix empty state message

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

Change 635898 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Fix empty state message

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

Etonkovidova subscribed.

@AnneT - the issue is fixed in betalabs for uselang=he.

Screen Shot 2020-10-27 at 3.40.53 PM.png (424×884 px, 38 KB)

However, I looked at the message - wikibasemediainfo-special-mediasearch-empty-state ( https://translatewiki.net/wiki/Special:Translations?message=MediaWiki%3Awikibasemediainfo-special-mediasearch-empty-state&namespace=8) (it has not been translated into too many languages yet, so it was easy to check all languages to which it was translated) and there are the following issues
(1) for Hindi the issue is still present. The message in the table looks as the following:

<span class="wbmi-media-search--empty-state__file-count">$1</span> {{PLURAL:$1|मीडिया फ़ाइल|मीडिया फ़ाइलें}} उस {{PLURAL:$ 1| ।है।हैं}} फिर से उपयोग करने के लिए स्वतंत्र

In betalabs, the fix works partially - the markup is not displayed, but the variables placeholders are displayed.

betalabs displays the variables placeholdersproduction displays markup and variables
Screen Shot 2020-10-27 at 4.20.35 PM.png (471×941 px, 50 KB)
Screen Shot 2020-10-27 at 4.24.01 PM.png (433×898 px, 53 KB)

(2) (a minor issue) for Turkish (tr) and Traditional Chinese (zh-hant) the number is not bold (the screenshots are from betalabs, but it's the same in production):

Screen Shot 2020-10-27 at 4.32.25 PM.png (314×578 px, 21 KB)
Screen Shot 2020-10-27 at 4.32.51 PM.png (379×789 px, 45 KB)

(3) for Macedonian (lang code - mk) language - the message is repeated

"Пребарајте повеќе од <span class="wbmi-media-search-empty-state__file-count">$1</span> {{PLURAL:$1|податотека|податотеки}} {{PLURAL:$1|која е|кои се}} за слободна пренамена

<span class="wbmi-media-search-empty-state__file-count">$1</span> {{PLURAL:$1|податотека|податотеки}} за слободна пренамена

which renders as following:

<div class="wbmi-media-search-empty-state"><div class="wbmi-media-search-empty-state__icon"></div> <p>Пребарајте повеќе од <span class="wbmi-media-search-empty-state__file-count">65372597</span> податотеки кои се за слободна пренамена

<span class="wbmi-media-search-empty-state__file-count">65372597</span> податотеки за слободна пренамена</p></div>

Screen Shot 2020-11-02 at 3.10.42 PM.png (533×883 px, 65 KB)

Looked into some messages that have styling, e.g.

Screen Shot 2020-10-29 at 5.02.27 PM.png (190×651 px, 23 KB)

growthexperiments-homepage-suggestededits-footer: (growthexperiments-homepage-suggestededits-footer-megasuffix). On translatewiki.net, the messages do not have markup

Other users have noted these articles need work. Help make '''{{SITENAME}}''' better for its '''$1 readers''' each day.

$1M

Another example will be - MediaWiki:Growthexperiments-homepage-startediting-dialog-intro-response-add-image

<strong>When {{GENDER:|you}} created {{GENDER:|your}} account, {{GENDER:|you}} said {{GENDER:|you}} wanted to add a photo or image.</strong> That's an important but challenging way to edit, so we recommend {{GENDER:|you}} try some simple edits first. If {{GENDER:|you}} would rather go straight to adding a photo or image, {{GENDER:|you}} can [$1 learn how here].

But <strong> tag there is not for visual emphasis, so it is not an example for message with markup strictly speaking.

The cause of this issue is T249892: mw.message.parse() should not escape HTML returned from magic words (e.g. {{PLURAL}}). The Hebrew translation of the message looks something like Search more than {{PLURAL:$1|<span class="...">one</span> file that is|<span class="...">$1</span> files that are}} free to use. This syntax (putting HTML syntax inside of a PLURAL magic word) works in PHP, but breaks in JavaScript because of a bug.

Making the message a raw HTML message, as the patch did, works around this bug but is not advised. An alternative workaround would be to restructure the Hebrew translation to instead look like Search more than <span class="...">{{PLURAL:$1|one|$1}}</span> that {{PLURAL:$1|is|are}} free to use.

I've edited the Hebrew message on TWN to work around this bug: https://translatewiki.net/w/i.php?title=MediaWiki:Wikibasemediainfo-special-mediasearch-empty-state/he&diff=prev&oldid=9688010

Advice for people doing this in the future: editing a mix of Hebrew, English and punctuation characters is really hard. To keep yourself sane, inspect the <textarea> in your browser inspector, change its dir attribute to dir="ltr", and add the CSS rule unicode-bidi: bidi-override

Change 632958 had a related patch set uploaded (by Amire80; owner: Amire80):
[mediawiki/extensions/WikibaseMediaInfo@master] Simplify wikibasemediainfo-special-mediasearch-empty-state

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

This message generally seems unnecessarily complex to me. I sent https://gerrit.wikimedia.org/r/632958 some time ago, and perhaps it can address this issue nicely, too. (But it's also possible that I am missing something...)

Thanks for all the information @Catrope, and for the suggested change @Amire80. I'd suggest we simplify it even further by removing the span and CSS class altogether - it's only there so we can set the font weight of the number of files, which I would argue is not worth all this hassle. @mwilliams, what do you think?

@AnneT Agreed, if it's a hassle, lose it!

Change 632958 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Simplify wikibasemediainfo-special-mediasearch-empty-state

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

I also agree with the following comment .

Thanks for all the information @Catrope, and for the suggested change @Amire80. I'd suggest we simplify it even further by removing the span and CSS class altogether - it's only there so we can set the font weight of the number of files, which I would argue is not worth all this hassle. @mwilliams, what do you think?

The issue has been checked in wmf.16 - and it's fixed there; will wait for wmf.17 to re-check for the patch above.

Change 654287 had a related patch set uploaded (by Anne Tomasevich; owner: Anne Tomasevich):
[mediawiki/extensions/WikibaseMediaInfo@master] Remove markup from empty state message

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

Change 654287 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Remove markup from empty state message

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