https://bugzilla.wikimedia.org/show_bug.cgi?id=45385

       Web browser: ---
            Bug ID: 45385
           Summary: MWTimestamp::getHumanTimestamp() unlocalizable
           Product: MediaWiki
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: Unprioritized
         Component: Internationalization
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]
    Classification: Unclassified
   Mobile Platform: ---

Some time ago, I pointed out at [1] that the [[MediaWiki:Ago]] message is
untranslatable and should not be used. Some time after that, a nice
human-readable timestamp system was implemented [2], however, after a lot of
bikeshedding talk [3], the change was reverted. Currently, MediaWiki does not
have a useful implementation of human-readable timestamps, but it still has a
broken implementation of those in MWTimestamp::getHumanTimestamp(), which is
slowly getting used in various places.

A short summary of the problems with the current implementation:

In flective languages, you cannot use a single piece of text (e.g. “$1
seconds”) both in a sentence like “It took $1 to render the image.”, and in a
sentence like “The image was rendered $1 ago.” E.g. in Czech, the first use
(duration) needs nominative case, while the second use (time ago) needs
instrumental case: Something took “5 _sekund_”, but it happened “před 5
_sekundami_”. Therefore, the ago message cannot use the basic messages for time
units (seconds, minutes, ...), it needs separate versions of those. Also, note
that while some of those messages were used in MediaWiki for a long time, some
of those newly appeared for these “ago” uses, and have even been _documented_
as “Part of variable $1 in {{msg-mw|Ago}}”! Which makes it a complete mess; the
current Czech translation uses instrumental for half of these messages, and
nominative for the other half of them.

Another problem is the current structure/placement of the formatting code: It
is placed in the language-independent MWTimestamp class, and supposedly returns
a language-independent Message instance, as is assumed in its unit test, where
code like
  $timestamp->getHumanTimestamp()->inLanguage( 'en' )->text()
is used. It seems nice until you figure that it cannot work. Try replacing it
with e.g.
  $timestamp->getHumanTimestamp()->inLanguage( 'cs' )->text()
and you’ll get something like “před 3 hours”, i.e. the “ago” message is
“inLanguage( 'cs' )”, but the inner $1 has already been replaced with a
non-inLanguaged “hours” message in the default wiki language (!). The point is
the method should reside inside Language just like e.g. formatTimePeriod (and
like it was in [2]), and, if it is placed elsewhere, it needs to get the
language as an argument. (I would be able to imagine the Message class having a
slightly more powerful API with a “deep knowledge” of parameters, and being
able to apply inLanguage recursively on them, but I think that would be a bit
overcomplicated.)

    [1]
http://translatewiki.net/wiki/Thread:Support/ago_%28%22$1_ago%22%29_cannot_work
    [2] https://gerrit.wikimedia.org/r/#/c/15746
    [3]
http://comments.gmane.org/gmane.science.linguistics.wikipedia.technical/64765
    [4] https://gerrit.wikimedia.org/r/#/c/29947

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to