do proper pluralization for JS
This commit is contained in:
parent
9ecc3005c4
commit
c5654a43db
50 changed files with 71 additions and 74 deletions
|
|
@ -16,26 +16,6 @@ module ApplicationHelper
|
|||
"javascript:(function(){f='#{AppConfig[:pod_url]}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'¬es='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=1&';a=function(){if(!window.open(f+'noui=1&jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=620,height=250'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"
|
||||
end
|
||||
|
||||
def get_javascript_strings_for(language)
|
||||
defaults = I18n.t('javascripts', :locale => DEFAULT_LANGUAGE)
|
||||
|
||||
if language != DEFAULT_LANGUAGE
|
||||
translations = I18n.t('javascripts', :locale => language)
|
||||
defaults.deep_merge!(translations)
|
||||
end
|
||||
|
||||
defaults
|
||||
end
|
||||
|
||||
def direction_for(string)
|
||||
return '' unless string.respond_to?(:cleaned_is_rtl?)
|
||||
string.cleaned_is_rtl? ? 'rtl' : 'ltr'
|
||||
end
|
||||
|
||||
def rtl?
|
||||
@rtl ||= RTL_LANGUAGES.include? I18n.locale
|
||||
end
|
||||
|
||||
def contacts_link
|
||||
if current_user.contacts.size > 0
|
||||
contacts_path
|
||||
|
|
|
|||
|
|
@ -6,4 +6,26 @@ module LanguageHelper
|
|||
end
|
||||
options.sort_by { |o| o[0] }
|
||||
end
|
||||
end
|
||||
|
||||
def get_javascript_strings_for(language)
|
||||
defaults = I18n.t('javascripts', :locale => DEFAULT_LANGUAGE)
|
||||
|
||||
if language != DEFAULT_LANGUAGE
|
||||
translations = I18n.t('javascripts', :locale => language)
|
||||
defaults.deep_merge!(translations)
|
||||
end
|
||||
|
||||
defaults['pluralization_rule'] = I18n.t 'i18n.plural.js_rule', :locale => language
|
||||
|
||||
defaults
|
||||
end
|
||||
|
||||
def direction_for(string)
|
||||
return '' unless string.respond_to?(:cleaned_is_rtl?)
|
||||
string.cleaned_is_rtl? ? 'rtl' : 'ltr'
|
||||
end
|
||||
|
||||
def rtl?
|
||||
@rtl ||= RTL_LANGUAGES.include? I18n.locale
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
{ :ar => { :i18n => {:plural => { :keys => [:zero, :one, :two, :few, :many, :other], :rule => lambda { |n| n == 0 ? :zero : n == 1 ? :one : n == 2 ? :two : [3, 4, 5, 6, 7, 8, 9, 10].include?(n % 100) ? :few : [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99].include?(n % 100) ? :many : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :bg => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :br => { :i18n => {:plural => { :keys => [:one, :two, :few, :many, :other], :rule => lambda { |n| n % 10 == 1 && n ? :one : n % 10 == 2 && n ? :two : [3, 4].include?(n % 10) && ![10, 11, 12, 13, 14, 15, 16, 17, 18, 19].include?(n % 100) ? :few : n % 1000000 == 0 && n != 0 ? :many : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :ca => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :cs => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : [2, 3, 4].include?(n) ? :few : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :cy => { :i18n => {:plural => { :keys => [:zero, :one, :two, :few, :many, :other], :rule => lambda { |n| n == 0 ? :zero : n == 1 ? :one : n == 2 ? :two : n == 3 ? :few : n == 6 ? :many : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :da => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :de => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :el => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :en => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :eo => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :es => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :eu => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :fi => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :fil => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| [0, 1].include?(n) ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :fr => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n && n != 2 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :ga => { :i18n => {:plural => { :keys => [:one, :two, :few, :many, :other], :rule => lambda { |n| n == 1 ? :one : n == 2 ? :two : [3, 4, 5, 6].include?(n) ? :few : [7, 8, 9, 10].include?(n) ? :many : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :gl => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :he => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :hu => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :id => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :is => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :it => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :ja => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :ka => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :ko => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :lt => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n % 10 == 1 && ![11, 12, 13, 14, 15, 16, 17, 18, 19].include?(n % 100) ? :one : [2, 3, 4, 5, 6, 7, 8, 9].include?(n % 10) && ![11, 12, 13, 14, 15, 16, 17, 18, 19].include?(n % 100) ? :few : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :mk => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n % 10 == 1 && n != 11 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :ml => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :ms => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :nb => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :nl => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :nn => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :pa => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :pl => { :i18n => {:plural => { :keys => [:one, :few, :many, :other], :rule => lambda { |n| n == 1 ? :one : [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100) ? :few : n != 1 && [0, 1].include?(n % 10) || [5, 6, 7, 8, 9].include?(n % 10) || [12, 13, 14].include?(n % 100) ? :many : :other } } } } }
|
||||
46
config/locales/cldr/plurals.rb
Normal file
46
config/locales/cldr/plurals.rb
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{:ar => { :i18n => {:plural => { :keys => [:zero, :one, :two, :few, :many, :other], :rule => lambda { |n| n == 0 ? :zero : n == 1 ? :one : n == 2 ? :two : [3, 4, 5, 6, 7, 8, 9, 10].include?(n % 100) ? :few : [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99].include?(n % 100) ? :many : :other }, :js_rule => 'function (n) { return n == 0 ? "zero" : n == 1 ? "one" : n == 2 ? "two" : (jQuery.inArray(n % 100, [3, 4, 5, 6, 7, 8, 9, 10]) != -1) ? "few" : (jQuery.inArray(n % 100, [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) != -1) ? "many" : "other" }' } } },
|
||||
:bg => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:br => { :i18n => {:plural => { :keys => [:one, :two, :few, :many, :other], :rule => lambda { |n| n % 10 == 1 && n ? :one : n % 10 == 2 && n ? :two : [3, 4].include?(n % 10) && ![10, 11, 12, 13, 14, 15, 16, 17, 18, 19].include?(n % 100) ? :few : n % 1000000 == 0 && n != 0 ? :many : :other }, :js_rule => 'function (n) { return n % 10 == 1 && n ? "one" : n % 10 == 2 && n ? "two" : (jQuery.inArray(n % 10, [3, 4]) != -1) && !(jQuery.inArray(n % 100, [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) != -1) ? "few" : n % 1000000 == 0 && n != 0 ? "many" : "other" }' } } },
|
||||
:ca => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:cs => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : [2, 3, 4].include?(n) ? :few : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : (jQuery.inArray(n, [2, 3, 4]) != -1) ? "few" : "other" }' } } },
|
||||
:cy => { :i18n => {:plural => { :keys => [:zero, :one, :two, :few, :many, :other], :rule => lambda { |n| n == 0 ? :zero : n == 1 ? :one : n == 2 ? :two : n == 3 ? :few : n == 6 ? :many : :other }, :js_rule => 'function (n) { return n == 0 ? "zero" : n == 1 ? "one" : n == 2 ? "two" : n == 3 ? "few" : n == 6 ? "many" : "other" }' } } },
|
||||
:da => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:de => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:el => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:en => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:eo => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:es => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:eu => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:fi => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:fil => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| [0, 1].include?(n) ? :one : :other }, :js_rule => 'function (n) { return (jQuery.inArray(n, [0, 1]) != -1) ? "one" : "other" }' } } },
|
||||
:fr => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n && n != 2 ? :one : :other }, :js_rule => 'function (n) { return n && n != 2 ? "one" : "other" }' } } },
|
||||
:ga => { :i18n => {:plural => { :keys => [:one, :two, :few, :many, :other], :rule => lambda { |n| n == 1 ? :one : n == 2 ? :two : [3, 4, 5, 6].include?(n) ? :few : [7, 8, 9, 10].include?(n) ? :many : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : n == 2 ? "two" : (jQuery.inArray(n, [3, 4, 5, 6]) != -1) ? "few" : (jQuery.inArray(n, [7, 8, 9, 10]) != -1) ? "many" : "other" }' } } },
|
||||
:gl => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:he => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:hu => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other }, :js_rule => 'function (n) { return "other" }' } } },
|
||||
:id => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other }, :js_rule => 'function (n) { return "other" }' } } },
|
||||
:is => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:it => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:ja => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other }, :js_rule => 'function (n) { return "other" }' } } },
|
||||
:ka => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other }, :js_rule => 'function (n) { return "other" }' } } },
|
||||
:ko => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other }, :js_rule => 'function (n) { return "other" }' } } },
|
||||
:lt => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n % 10 == 1 && ![11, 12, 13, 14, 15, 16, 17, 18, 19].include?(n % 100) ? :one : [2, 3, 4, 5, 6, 7, 8, 9].include?(n % 10) && ![11, 12, 13, 14, 15, 16, 17, 18, 19].include?(n % 100) ? :few : :other }, :js_rule => 'function (n) { return n % 10 == 1 && !(jQuery.inArray(n % 100, [11, 12, 13, 14, 15, 16, 17, 18, 19]) != -1) ? "one" : (jQuery.inArray(n % 10, [2, 3, 4, 5, 6, 7, 8, 9]) != -1) && !(jQuery.inArray(n % 100, [11, 12, 13, 14, 15, 16, 17, 18, 19]) != -1) ? "few" : "other" }' } } },
|
||||
:mk => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n % 10 == 1 && n != 11 ? :one : :other }, :js_rule => 'function (n) { return n % 10 == 1 && n != 11 ? "one" : "other" }' } } },
|
||||
:ml => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:ms => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other }, :js_rule => 'function (n) { return "other" }' } } },
|
||||
:nb => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:nl => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:nn => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:pa => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:pl => { :i18n => {:plural => { :keys => [:one, :few, :many, :other], :rule => lambda { |n| n == 1 ? :one : [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100) ? :few : n != 1 && [0, 1].include?(n % 10) || [5, 6, 7, 8, 9].include?(n % 10) || [12, 13, 14].include?(n % 100) ? :many : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : (jQuery.inArray(n % 10, [2, 3, 4]) != -1) && !(jQuery.inArray(n % 100, [12, 13, 14]) != -1) ? "few" : n != 1 && (jQuery.inArray(n % 10, [0, 1]) != -1) || (jQuery.inArray(n % 10, [5, 6, 7, 8, 9]) != -1) || (jQuery.inArray(n % 100, [12, 13, 14]) != -1) ? "many" : "other" }' } } },
|
||||
:ro => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : n == 0 ? :few : :other }, :js_rule => 'function (n) { return 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 }, :js_rule => 'function (n) { return n % 10 == 1 && n % 100 != 11 ? "one" : (jQuery.inArray(n % 10, [2, 3, 4]) != -1) && !(jQuery.inArray(n % 100, [12, 13, 14]) != -1) ? "few" : n % 10 == 0 || (jQuery.inArray(n % 10, [5, 6, 7, 8, 9]) != -1) || (jQuery.inArray(n % 100, [11, 12, 13, 14]) != -1) ? "many" : "other" }' } } },
|
||||
:sk => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : [2, 3, 4].include?(n) ? :few : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : (jQuery.inArray(n, [2, 3, 4]) != -1) ? "few" : "other" }' } } },
|
||||
:sl => { :i18n => {:plural => { :keys => [:one, :two, :few, :other], :rule => lambda { |n| n % 100 == 1 ? :one : n % 100 == 2 ? :two : [3, 4].include?(n % 100) ? :few : :other }, :js_rule => 'function (n) { return n % 100 == 1 ? "one" : n % 100 == 2 ? "two" : (jQuery.inArray(n % 100, [3, 4]) != -1) ? "few" : "other" }' } } },
|
||||
:sq => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:sv => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:te => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:tr => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other }, :js_rule => 'function (n) { return "other" }' } } },
|
||||
:uk => { :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 }, :js_rule => 'function (n) { return n % 10 == 1 && n % 100 != 11 ? "one" : (jQuery.inArray(n % 10, [2, 3, 4]) != -1) && !(jQuery.inArray(n % 100, [12, 13, 14]) != -1) ? "few" : n % 10 == 0 || (jQuery.inArray(n % 10, [5, 6, 7, 8, 9]) != -1) || (jQuery.inArray(n % 100, [11, 12, 13, 14]) != -1) ? "many" : "other" }' } } },
|
||||
:ur => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other }, :js_rule => 'function (n) { return n == 1 ? "one" : "other" }' } } },
|
||||
:vi => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other }, :js_rule => 'function (n) { return "other" }' } } }}
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :ro => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : n == 0 ? :few : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :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 } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :sk => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : [2, 3, 4].include?(n) ? :few : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :sl => { :i18n => {:plural => { :keys => [:one, :two, :few, :other], :rule => lambda { |n| n % 100 == 1 ? :one : n % 100 == 2 ? :two : [3, 4].include?(n % 100) ? :few : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :sq => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :sv => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :te => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :tr => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :uk => { :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 } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :ur => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ :vi => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
loadLocale: function(locale, language) {
|
||||
this.locale = locale;
|
||||
this.language = language;
|
||||
eval("this.pluralizationKey = "+this.t('pluralization_rule'));
|
||||
},
|
||||
|
||||
t: function(item, views) {
|
||||
|
|
@ -27,13 +28,7 @@
|
|||
}
|
||||
|
||||
if(views && typeof views.count !== "undefined") {
|
||||
if(views.count == 0) { nextNamespace = "zero"; } else
|
||||
if(views.count == 1) { nextNamespace = "one"; } else
|
||||
if(views.count <= 3) { nextNamespace = "few"; } else
|
||||
if(views.count > 3) { nextNamespace = "many"; }
|
||||
else { nextNamespace = "other"; }
|
||||
|
||||
translatedMessage = translatedMessage[nextNamespace];
|
||||
translatedMessage = translatedMessage[this.pluralizationKey(views.count)];
|
||||
}
|
||||
|
||||
return _.template(translatedMessage, views || {});
|
||||
|
|
|
|||
Loading…
Reference in a new issue