Page MenuHomePhabricator

Block log items on RecentChanges don't make use of possible translations
Closed, ResolvedPublic

Description

Author: spacebirdy

Description:
Hello all,
in the recent changes the block duration is still shown in English if changed in
[[MediaWiki:Ipboptions]]
although in the [[Special:Log/block]] it is shown correctly.

examples:
Time (Aktuell; Vorherige) . . Admin(Diskussion | Beiträge) (blockiert
Benutzer:someUser für einen Zeitraum von: 2 hours: reason)
[[:w:de:Spezial:Recentchanges]] -> (Benutzerblockaden-Logbuch)
but correct shown in :[[:w:de:Spezial:Log/block]] -> "2 Stunden" instead of "2
hours"

other example: compare
[[:w:fr:Special:Log/block]]
[[:w:fr:Special:Recentchanges]] -> (Historique des blocages)

same on other wikies and wikties: de, fr, es, ...

Many thanks in advance for your help,
best regards,
Elisabeth Anderl ([[:wikt:is:Notandi:Spacebirdy]])


Version: unspecified
Severity: normal

Details

Reference
bz5387

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:11 PM
bzimport set Reference to bz5387.
bzimport added a subscriber: Unknown Object (MLST).

spacebirdy wrote:

examples:
Time (Aktuell; Vorherige) . . Admin(Diskussion | Beiträge) (blockiert
Benutzer:someUser für einen Zeitraum von: 2 hours: reason)
[[w:de:Spezial:Recentchanges]] -> (Benutzerblockaden-Logbuch)
but correct shown in :[[w:de:Spezial:Log/block]] -> "2 Stunden" instead of "2
hours"

other example: compare
[[w:fr:Special:Log/block]]
[[w:fr:Special:Recentchanges]] -> (Historique des blocages)

correcting the links (I hope so)

spacebirdy wrote:

(In reply to comment #1)

examples:
Time (Aktuell; Vorherige) . . Admin(Diskussion | Beiträge) (blockiert
Benutzer:someUser für einen Zeitraum von: 2 hours: reason)
[[de:Spezial:Recentchanges]] -> (Benutzerblockaden-Logbuch)
but correct shown in :[[de:Spezial:Log/block]] -> "2 Stunden" instead of "2
hours"

other example: compare
[[fr:Special:Log/block]]
[[fr:Special:Recentchanges]] -> (Historique des blocages)

hmpf, sorry, what I need is a preview button ;(, I hope this works now

gangleri wrote:

Was this fixed together with
Bug 5592: Set the logs fixed text in Recent Changes as the site language, not
the user's one ?

rotemliss wrote:

(In reply to comment #3)

Was this fixed together with
Bug 5592: Set the logs fixed text in Recent Changes as the site language, not
the user's one ?

I don't think so, but I will check it.

rotemliss wrote:

Patch (trunk)

The patch fixes the problem in the trunk. Patch for REL1_6 is coming soon.

The patch does, technically, the following things:

  • In LogPage::actionText (includes/LogPage.php), there was a parameter named

$translate (by default false (when getting the text for the recent changes),
when calling from LogViewer::LogLine (includes/SpecialLog.php) true) as a
condition for translating the block expiry time expression (in addition to the
basic condition that the log action will be "block", else there is no time
exrpession). It was canceled, and all its references were deleted.

  • This variable was originally created because the translated time expression

wasn't shown well in the recent changes – they've included a span HTML tag,
which was shown because no HTML is allowed in the recent changes comments. This
span was invented to pop-up the original time expression, in the original
formatting; however, it is not useful for most of the people, and the other can
go to the block log and see it if they want. This span was in the return value
of the functions Language::translateBlockExpiry (languages/Language.php) and
LanguageFi::translateBlockExpiry (languages/LanguageFi.php). This patch has
moved the span to LogPage::actionText (includes/LogPage.php), if it is $skin
(that means, the block log) – else (that means, the recent changes), no span
is used.

  • In Language::translateBlockExpiry (languages/Language.php), wfMsg is used.

However, in the recent changes we should use the content language (because the
log is actually an edit summary), so it was replaced the wfMsgForContent if the
object and $wgContLang class names are equal – else, wfMsg is used. It is not
a good hack, but it is already used in Language.php, and it works.

It seems long, but it isn't. I've just documented the patch as much as possible
here, for you will easily review it.

attachment patch ignored as obsolete

rotemliss wrote:

Patch (REL1_6)

Just the same.

By the way, there is a command for SVN used to merge a patch into existing SVN
directories? I've checked in the manual, and searched in the commands list (svn
help), but I haven't found any command like that (svn merge is used for another
purpose, as far as I understand). For example, I've downloaded MediaWiki from
the SVN, downloaded a patch from here, and want to merge the patch changes into
my SVN directories to check it, or to improve it. Should I do that manually, or
there is an automatic way? Thanks if you reply, it will help me a lot creating
fixes for MediaWiki.

attachment patch ignored as obsolete

This issue is bogus; the block durations are customizable and
may change order, size, amount, number, etc. There's no
available translation information to back such a feature.

Re comment 6: use the standard Unix patch utility.

rotemliss wrote:

(In reply to comment #7)

This issue is bogus; the block durations are customizable and
may change order, size, amount, number, etc. There's no
available translation information to back such a feature.

It is translated in the block log, and most of the blocks are done using the
translated options. Also, if we have available translation for something, we
better use it – like we use the English translation if no local translation is
exist, and we don't say "there is no available translation for EVERY string,
English strings will confuse the users, so we better don't use the translation
at all if it isn't complete".

Also, if a site uses an expiry time which is not listed (and has no
translation), its sysops can add it into "ipboptions", and it will have
translation. There is no reason to confuse users with English phrases if we have
an available translation. Also, most of the site sysops are probably
non-technical people, which will most likely use an item from the list.

Re comment 6: use the standard Unix patch utility.

Thanks, I will try that.

There is no "English translation". The available option contains a list of
entries, each composed of a machine-readable duration and a localized display
string.

rotemliss wrote:

(In reply to comment #9)

There is no "English translation". The available option contains a list of
entries, each composed of a machine-readable duration and a localized display
string.

And both the block log and the recent changes should use the localized display
string (if available) when showing the items of "X blocked Y for the duration of
Z". The block log shows the localized string, but the recent changes shows the
machine-readable duration. The recent changes should also show the localized
string, and the patch changes the recent changes view so the page *will* show
the localized string.

Ah, ok I see what you mean.

Not sure the patch makes sense totally though. There's some really
crappy existing code in there; translateBlockExpiry needs to be
ripped out and replaced with something that makes sense. It seems
halfway done but not all there.

What's this for instance supposed to be doing? :)
+ return '”'.htmlspecialchars( trim( $final ) ).'”';

rotemliss wrote:

(In reply to comment #11)

Not sure the patch makes sense totally though. There's some really
crappy existing code in there; translateBlockExpiry needs to be
ripped out and replaced with something that makes sense. It seems
halfway done but not all there.

You may improve the patch and rewrite the whole code.

What's this for instance supposed to be doing? :)
+ return '”'.htmlspecialchars( trim( $final ) ).'”';

This code returns the localized time expiry from the function (in
LanguageFi.php), with trim, htmlspecialchars and the quotes, like the original
code but without the original '<span title="X">' which is inserted in another
part of the code. (The original code doesn't use htmlspecialchars, but the code
in Language.php does, so the code in LanguageFi.php also should use
htmlspecialchars.)

rotemliss wrote:

*** Bug 2775 has been marked as a duplicate of this bug. ***

rotemliss wrote:

Alternative Patch (trunk)

This patch completely rewrites Language::translateBlockExpiry: now it first
checks if $str is "inifinite", then uses the message "infiniteblock"
immediantly; else, it explodes the string by spaces, goes over the array,
parses the strings (for example, in "7 months 3 weeks", parses "7 months" and
"3 weeks" separatly) using the new "nseconds", "nminutes", "nhours", "ndays",
"nweeks", "nmonths" and "nyears" messages; then it adds the parsed string to
the array $result (if didn't succeed to parse, it adds the original phrase),
and returns this imploded array.

The final result of this script is a clean output, also for "7 months" and "7
months 3 weeks". This rewriting does not depend on "ipblockoptions" for
translation, and is much more logical.

By the way, "ipboptions" was removed, and replaced by the unlocalizable
"blockoptions", which includes only the original phrases and ommits the
translation. We should have a way to change the block options in the site,
however it shouldn't be confused with the translation of the time phrases.
[[Special:Blockip]] now uses the improved Language::translateBlockExpiry.

Unluckily, I was forced to duplicate "wfMsgExt" into "wfMsgExtForContent".

Of course this patch is not for REL1_6, but for trunk only. I think it makes
sense and should be inserted. I've checked this patch on my computer and it
works very well.

attachment patch ignored as obsolete

rotemliss wrote:

Alternative Patch (trunk)

Typo.

attachment patch ignored as obsolete

rotemliss wrote:

Alternative Patch (trunk)

Another typo.

attachment patch ignored as obsolete

rotemliss wrote:

Alternative Patch v2 (trunk)

This patch fixes some problems in the old patch:

  1. "infiniteblock" message could not be locally changed (in MediaWiki:

namespace).

  1. An error in the parsing (created a paragraph around each result), now using

"parsemag" instead of "parse".

  1. Allowing the special form of "2 hours" in Hebrew, by the new third parameter

of "plural" there.
I think my proposed Language::translateBlockExpiry is much more logical than
the current one, as it can translate every time phrase to the local language as
far as I've checked.

attachment blocklog.patch.txt ignored as obsolete

rotemliss wrote:

Alternative Patch v3 (trunk)

Updating the patch line numbers, to make its applying easier.

attachment patch ignored as obsolete

rotemliss wrote:

Patch v2 (trunk)

Some lines were changed – matching the patch to the current revision.

Attached:

rotemliss wrote:

Comment on attachment 1590
Patch (REL1_6)

Not suitable for branch.

rotemliss wrote:

Alternative Patch v4 (trunk)

Updating the line numbers.

Attached:

  • Bug 7307 has been marked as a duplicate of this bug. ***
  • Bug 7674 has been marked as a duplicate of this bug. ***
  • Bug 10138 has been marked as a duplicate of this bug. ***

This will be dealt with when revisiondelete is merged in. Also, rob will do additional cleanup and generalizing likely.

rotemliss wrote:

Fixed in r25709. The alternative patch is a fix for another bug (something like "Don't translate block expiry times using ipboptions, but directly") and obviously needs updating.