Issue Details (XML | Word | Printable)

Key: MBS-4268
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Normal Normal
Assignee: Ian McEwen
Reporter: nikki
Votes: 2
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
MusicBrainz Server

"{age} ago" does not work for all languages

Created: 02/Feb/12 12:58 AM   Updated: 16/Oct/12 07:55 PM   Resolved: 16/Oct/12 07:55 PM
Component/s: Internationalization
Affects Version/s: None
Fix Version/s: Schema change, 2012-10-15


 Description  « Hide

In root/components/common-macros.tt we use "{age} ago" (where "age" is a variable containing something like "3 days") as the translatable string ("ago" is also used in root/label/layout.tt, root/artist/layout.tt and root/artist/index.tt but there we're not even trying to translate it). This doesn't work in several languages, e.g. German ("3 days" is "3 Tage", "3 days ago" is "vor 3 Tagen") or Hungarian (see http://chatlogs.musicbrainz.org/musicbrainz/2012/2012-02/2012-02-02.html#T00-54-09-87246 ).



Sort Order: Ascending order - Click to sort in descending order
Oliver Charles added a comment - 02/Feb/12 10:18 AM

Essentially, I guess we need to have some logic like:

sub x_units_ago {
    my ($x, $units) = @_;
    given($units) {
        when ('hours') { ln('{x} hours ago', ...) }
        when ('days') { ln('{x} days ago', ...) }
        when ('months') { ln('{x} months ago', ...) }
    }    
}

Right?


nikki added a comment - 02/Feb/12 10:23 AM

Yes, that should work.


Oliver Charles added a comment - 02/Feb/12 10:39 AM

Ok, this is the kind of thing that the lexicon stuff does. If we end up doing this alot (ourselves), we'll basically be re-inventing it I wonder what the best way to proceed is.


Oliver Charles added a comment - 02/Feb/12 10:43 AM

Found the article about the lexicon stuff, it's http://search.cpan.org/~jhi/perl-5.8.1/lib/Locale/Maketext/TPJ13.pod.


Ian McEwen added a comment - 03/Feb/12 01:11 PM

We could use Time::Duration's 'ago': https://metacpan.org/module/Time::Duration#ago-seconds- and then add the appropriate ln() calls in a dummy function somewhere. Since we're using a precision of one, we just need:

{x} year/day/hour/minute/second(s) ago

Which is five strings. This isn't Locale::Maketext's use case; if we were using Time::Duration's default of two unit-types precision we'd run into the complicated multiple-pluralizations-in-the-same-string problem, which is where Maketext starts making more sense (FSVO "more sense" – Maketext is needlessly complicated IMO, and I really doubt we need it).


Oliver Charles added a comment - 03/Feb/12 02:07 PM

Feel free to investigate whatever line seems most appropriate - you folks are doing a better job at understanding i18n than I


Ian McEwen added a comment - 21/Sep/12 10:56 PM