Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Date - more complex plural forms #1037

Open
hamczu opened this Issue Sep 26, 2011 · 0 comments

Comments

Projects
None yet
1 participant

hamczu commented Sep 26, 2011

In many languages creating plural form from noun is more complex than check whether count > 1.
E.g. from polish localization:
minuteAgo: 'około minutę temu',
minutesAgo: '{delta} minut temu'

It's correct only when delta = 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 25, 26, etc.
So each language should have created plural forms rules in localisation,
and syntax should be little different:

plural: function(count){
    if ($count == 1){
        return 'one';
    }
    elseif (is_int($count) && ($i = $count % 10) >= 2 && $i <= 4 && ! (($i = $count % 100) >= 12 && $i <= 14) && ! ($i >= 22 && $i <= 24)){
        return 'few';
    } else {
        return 'other';
    }
},
minute_ago: {
     'one' : 'ok. minutę temu',
     'few' : '{delta} minuty temu',
     'other': '{delta} minut temu',
}

Good example of similar solution: https://github.com/czukowski/I18n_Plural (btw. author is a MooTools fan)

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment