Page MenuHomePhabricator

Syntax Highlighting: Translated magic words aren't recognized in Hebrew
Open, MediumPublic5 Estimated Story Points

Description

From IKhitron:

Localized magic words are highlighted as templates. Example: {{DEFAULTSORT:AAA}} vs {{מיון רגיל:AAA}}.

The English version is dark red, the translated versions are purple.

You can see it here: https://he.wikipedia.beta.wmflabs.org/w/index.php?title=%D7%99%D7%A4%D7%94_%D7%AA%D7%95%D7%A1%D7%99%D7%94_%D7%9B%D7%94%D7%9F&action=edit

The list of localized parser functions, can be retrieved with mw.config.get('extCodeMirrorConfig'); (look in functionSynonyms[0] and functionSynonyms[1]).

Translated magic words work fine in German and Dutch. Probably an RTL issue.

Event Timeline

DannyH triaged this task as Medium priority.Jul 7 2017, 5:55 PM
Pastakhov subscribed.

This is the expected behavior.
Localized magic words should be highlighted only on local wiki.
As you see, MW parser interprets them as Template:SORTIERUNG:AA and Template:מיון רגיל:AAA

Feel free to reopen the ticket if it will not work on local wiki

How exactly can we check it on local wiki, @Pastakhov?

I meant that it depends on the value of the $wgLanguageCode variable.
On test.wikipedia.org it is en thus there are no Localized magic words.
For check localized magic words you should set $wgLanguageCode to corresponded value.

I found other way - add uselang parameter to url, but it is more a bag that a feature (and should be fixed)
For example https://test.wikipedia.org/w/index.php?title=Pride_and_Prejudice&action=edit&oldid=323245&uselang=de
Or change it by language toolbar at the top of page. But in this case I see only part of language aliases.
Have no idea why.

I opened the link you gave, @Pastakhov. It does not work indeed.

I found other way - add uselang parameter to url, but it is more a bag that a feature (and should be fixed)
For example https://test.wikipedia.org/w/index.php?title=Pride_and_Prejudice&action=edit&oldid=323245&uselang=de
Or change it by language toolbar at the top of page. But in this case I see only part of language aliases.
Have no idea why.

beaware that uselang usually (unless there is very special hook in test wiki) only changes the UI language, not the content language of the site.

@IKhitron, It does not work since there are only part of language aliases (localized magic words).
And as I wrote, I have no idea why there are only part of them.
In any case this behavior is a bug, CodeMirror should use only language from $wgLanguageCode and it will be fixed soon.
For check localized magic words you should set $wgLanguageCode to corresponded value or use the CodeMirror extension on wiki with $wgLanguageCode have corresponded value (it's no joke).

@eranroz, yes, uselang should change the UI language only, but one affects also to list of Magic Words used in CodeMirror. Not sure where the bug is, in MW Core or CodeMirror, hope the bug in CodeMirror and will be easily fixed.

P.S. created another task T170130

You mean you actually expect I'll change the configuration of test.wikipedia.org?

@kaldari Is there a test wiki in any other language? It would help us to test that the magic words work properly on languages outside of English.

@kaldari Is there a test wiki in any other language? It would help us to test that the magic words work properly on languages outside of English.

We have the beta cluster which also has CodeMirror since I deployed it there. Here's the German version: https://de.wikipedia.beta.wmflabs.org/wiki/Wikipedia:Hauptseite I believe it needs a new account and doesn't work with CentralAuth. I could be wrong.

@IKhitron: I tried it out at https://de.wikipedia.beta.wmflabs.org/ and it seems to work correctly. "{{SORTIERUNG:AAA}}", the German localization for {{DEFAULTSORT}}, is correctly recognized as a magic word and highlighted as red instead of purple.

Thank you very much.

@kaldari, we have a problem. It does not work. See here. Thank you.

kaldari renamed this task from Syntax Highlighting: Translated magic words are treated like templates to Syntax Highlighting: Translated magic words aren't recognized in Hebrew.Jul 21 2017, 5:42 PM
kaldari reopened this task as Open.
kaldari updated the task description. (Show Details)

@IKhitron: I reopened and change the bug title and description.

kaldari set the point value for this task to 5.Jul 25 2017, 5:15 PM

I checked to see if this was a problem on Dutch Beta -- it works correctly there, as in the screenshot below. This is probably an RTL issue.

dutch syntax.png (586×1 px, 127 KB)

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

I was casually looking into this thing again...

First of all, there definitely is something wrong with this part of the code. If you take: {{DEFAULTSORT:AAAA}}
The regex stream.match(/^([^\s\u00a0}[\]<{'|&:]+)(:|[\s\u00a0]*)(\}\}?)?(.)?/); that it uses, matches and returns DEFAULTSORT:A (dropping three A's and the 3rd capture group is always undefined).. It probably should be more something the likes of ^([^}[\]<{'|&:]+)(:([^[\]<'|&:]*))?\}\}

But the reason the Hebrew version is not matching, and this took me a while to spot, is because it contains a space character. Magic words by convention do not have spaces, so this regex isn't expecting those and doesn't match on it.

I'm kinda surprised we have magic words with spaces, we should check how many other languages have magicwords with spaces and if that is ok or not.. (it probably is)

Change #1032770 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/CodeMirror@master] CodeMirrorModeMediaWiki: various small fixes

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