mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Update RU pluralization to use 3 keys: one, few, other (as by Transifex)
This commit is contained in:
parent
76824cda31
commit
c42a5551a1
3 changed files with 9 additions and 13 deletions
|
@ -3,8 +3,7 @@
|
|||
<%= JsLocaleHelper.output_locale(:ru) %>
|
||||
|
||||
I18n.pluralizationRules['ru'] = function (n) {
|
||||
if (n == 0) return ["zero", "none", "other"];
|
||||
if (n % 10 == 1 && n % 100 != 11) return "one";
|
||||
if (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20)) return "few";
|
||||
return "many";
|
||||
if (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14)) return "few";
|
||||
return "other";
|
||||
};
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
:pt => { :i18n => { :plural => { :keys => [:one, :other], :rule => lambda { |n| [0, 1].include?(n) ? :one : :other } } } },
|
||||
:"pt-PT" => { :i18n => { :plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } },
|
||||
:ro => { :i18n => { :plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : n == 0 ? :few : :other } } } },
|
||||
:ru => { :i18n => { :plural => { :keys => [:one, :few, :many, :other], :rule => lambda { |n| n % 10 == 1 && n % 100 != 11 ? :one : [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100) ? :few : n % 10 == 0 || [5, 6, 7, 8, 9].include?(n % 10) || [11, 12, 13, 14].include?(n % 100) ? :many : :other } } } },
|
||||
:ru => { :i18n => { :plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n % 10 == 1 && n % 100 != 11 ? :one : [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100) ? :few : :other } } } },
|
||||
:se => { :i18n => { :plural => { :keys => [:one, :two, :other], :rule => lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } } },
|
||||
:sh => { :i18n => { :plural => { :keys => [:one, :few, :many, :other], :rule => lambda { |n| n % 10 == 1 && n % 100 != 11 ? :one : [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100) ? :few : n % 10 == 0 || [5, 6, 7, 8, 9].include?(n % 10) || [11, 12, 13, 14].include?(n % 100) ? :many : :other } } } },
|
||||
:sk => { :i18n => { :plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : [2, 3, 4].include?(n) ? :few : :other } } } },
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
MessageFormat.locale.ru = function (n) {
|
||||
if ((n % 10) == 1 && (n % 100) != 11) {
|
||||
var r10 = n % 10, r100 = n % 100;
|
||||
|
||||
if (r10 == 1 && r100 != 11)
|
||||
return 'one';
|
||||
}
|
||||
if ((n % 10) >= 2 && (n % 10) <= 4 &&
|
||||
((n % 100) < 12 || (n % 100) > 14) && n == Math.floor(n)) {
|
||||
|
||||
if (r10 >= 2 && r10 <= 4 && (r100 < 12 || r100 > 14) && n == Math.floor(n))
|
||||
return 'few';
|
||||
}
|
||||
if ((n % 10) === 0 || ((n % 10) >= 5 && (n % 10) <= 9) ||
|
||||
((n % 100) >= 11 && (n % 100) <= 14) && n == Math.floor(n)) {
|
||||
return 'many';
|
||||
}
|
||||
|
||||
return 'other';
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue