From c5654a43db971da30bd5d2fecd113565c71e4448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Sat, 14 Jan 2012 20:27:06 +0100 Subject: [PATCH] do proper pluralization for JS --- app/helpers/application_helper.rb | 20 ------------- app/helpers/language_helper.rb | 24 +++++++++++++++- config/locales/cldr/ar_plurals.rb | 1 - config/locales/cldr/bg_plurals.rb | 1 - config/locales/cldr/br_plurals.rb | 1 - config/locales/cldr/ca_plurals.rb | 1 - config/locales/cldr/cs_plurals.rb | 1 - config/locales/cldr/cy_plurals.rb | 1 - config/locales/cldr/da_plurals.rb | 1 - config/locales/cldr/de_plurals.rb | 1 - config/locales/cldr/el_plurals.rb | 1 - config/locales/cldr/en_plurals.rb | 1 - config/locales/cldr/eo_plurals.rb | 1 - config/locales/cldr/es_plurals.rb | 1 - config/locales/cldr/eu_plurals.rb | 1 - config/locales/cldr/fi_plurals.rb | 1 - config/locales/cldr/fil_plurals.rb | 1 - config/locales/cldr/fr_plurals.rb | 1 - config/locales/cldr/ga_plurals.rb | 1 - config/locales/cldr/gl_plurals.rb | 1 - config/locales/cldr/he_plurals.rb | 1 - config/locales/cldr/hu_plurals.rb | 1 - config/locales/cldr/id_plurals.rb | 1 - config/locales/cldr/is_plurals.rb | 1 - config/locales/cldr/it_plurals.rb | 1 - config/locales/cldr/ja_plurals.rb | 1 - config/locales/cldr/ka_plurals.rb | 1 - config/locales/cldr/ko_plurals.rb | 1 - config/locales/cldr/lt_plurals.rb | 1 - config/locales/cldr/mk_plurals.rb | 1 - config/locales/cldr/ml_plurals.rb | 1 - config/locales/cldr/ms_plurals.rb | 1 - config/locales/cldr/nb_plurals.rb | 1 - config/locales/cldr/nl_plurals.rb | 1 - config/locales/cldr/nn_plurals.rb | 1 - config/locales/cldr/pa_plurals.rb | 1 - config/locales/cldr/pl_plurals.rb | 1 - config/locales/cldr/plurals.rb | 46 ++++++++++++++++++++++++++++++ config/locales/cldr/ro_plurals.rb | 1 - config/locales/cldr/ru_plurals.rb | 1 - config/locales/cldr/sk_plurals.rb | 1 - config/locales/cldr/sl_plurals.rb | 1 - config/locales/cldr/sq_plurals.rb | 1 - config/locales/cldr/sv_plurals.rb | 1 - config/locales/cldr/te_plurals.rb | 1 - config/locales/cldr/tr_plurals.rb | 1 - config/locales/cldr/uk_plurals.rb | 1 - config/locales/cldr/ur_plurals.rb | 1 - config/locales/cldr/vi_plurals.rb | 1 - public/javascripts/helpers/i18n.js | 9 ++---- 50 files changed, 71 insertions(+), 74 deletions(-) delete mode 100644 config/locales/cldr/ar_plurals.rb delete mode 100644 config/locales/cldr/bg_plurals.rb delete mode 100644 config/locales/cldr/br_plurals.rb delete mode 100644 config/locales/cldr/ca_plurals.rb delete mode 100644 config/locales/cldr/cs_plurals.rb delete mode 100644 config/locales/cldr/cy_plurals.rb delete mode 100644 config/locales/cldr/da_plurals.rb delete mode 100644 config/locales/cldr/de_plurals.rb delete mode 100644 config/locales/cldr/el_plurals.rb delete mode 100644 config/locales/cldr/en_plurals.rb delete mode 100644 config/locales/cldr/eo_plurals.rb delete mode 100644 config/locales/cldr/es_plurals.rb delete mode 100644 config/locales/cldr/eu_plurals.rb delete mode 100644 config/locales/cldr/fi_plurals.rb delete mode 100644 config/locales/cldr/fil_plurals.rb delete mode 100644 config/locales/cldr/fr_plurals.rb delete mode 100644 config/locales/cldr/ga_plurals.rb delete mode 100644 config/locales/cldr/gl_plurals.rb delete mode 100644 config/locales/cldr/he_plurals.rb delete mode 100644 config/locales/cldr/hu_plurals.rb delete mode 100644 config/locales/cldr/id_plurals.rb delete mode 100644 config/locales/cldr/is_plurals.rb delete mode 100644 config/locales/cldr/it_plurals.rb delete mode 100644 config/locales/cldr/ja_plurals.rb delete mode 100644 config/locales/cldr/ka_plurals.rb delete mode 100644 config/locales/cldr/ko_plurals.rb delete mode 100644 config/locales/cldr/lt_plurals.rb delete mode 100644 config/locales/cldr/mk_plurals.rb delete mode 100644 config/locales/cldr/ml_plurals.rb delete mode 100644 config/locales/cldr/ms_plurals.rb delete mode 100644 config/locales/cldr/nb_plurals.rb delete mode 100644 config/locales/cldr/nl_plurals.rb delete mode 100644 config/locales/cldr/nn_plurals.rb delete mode 100644 config/locales/cldr/pa_plurals.rb delete mode 100644 config/locales/cldr/pl_plurals.rb create mode 100644 config/locales/cldr/plurals.rb delete mode 100644 config/locales/cldr/ro_plurals.rb delete mode 100644 config/locales/cldr/ru_plurals.rb delete mode 100644 config/locales/cldr/sk_plurals.rb delete mode 100644 config/locales/cldr/sl_plurals.rb delete mode 100644 config/locales/cldr/sq_plurals.rb delete mode 100644 config/locales/cldr/sv_plurals.rb delete mode 100644 config/locales/cldr/te_plurals.rb delete mode 100644 config/locales/cldr/tr_plurals.rb delete mode 100644 config/locales/cldr/uk_plurals.rb delete mode 100644 config/locales/cldr/ur_plurals.rb delete mode 100644 config/locales/cldr/vi_plurals.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f8f6bac23..21752935c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/helpers/language_helper.rb b/app/helpers/language_helper.rb index 20a0db902..ea1d22de0 100644 --- a/app/helpers/language_helper.rb +++ b/app/helpers/language_helper.rb @@ -6,4 +6,26 @@ module LanguageHelper end options.sort_by { |o| o[0] } end -end \ No newline at end of file + + 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 diff --git a/config/locales/cldr/ar_plurals.rb b/config/locales/cldr/ar_plurals.rb deleted file mode 100644 index 21ae736b4..000000000 --- a/config/locales/cldr/ar_plurals.rb +++ /dev/null @@ -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 } } } } } \ No newline at end of file diff --git a/config/locales/cldr/bg_plurals.rb b/config/locales/cldr/bg_plurals.rb deleted file mode 100644 index 642df1b9f..000000000 --- a/config/locales/cldr/bg_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :bg => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/br_plurals.rb b/config/locales/cldr/br_plurals.rb deleted file mode 100644 index 0c566defe..000000000 --- a/config/locales/cldr/br_plurals.rb +++ /dev/null @@ -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 } } } } } \ No newline at end of file diff --git a/config/locales/cldr/ca_plurals.rb b/config/locales/cldr/ca_plurals.rb deleted file mode 100644 index 67f246d79..000000000 --- a/config/locales/cldr/ca_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :ca => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/cs_plurals.rb b/config/locales/cldr/cs_plurals.rb deleted file mode 100644 index 48115c7b2..000000000 --- a/config/locales/cldr/cs_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :cs => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : [2, 3, 4].include?(n) ? :few : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/cy_plurals.rb b/config/locales/cldr/cy_plurals.rb deleted file mode 100644 index b37dba436..000000000 --- a/config/locales/cldr/cy_plurals.rb +++ /dev/null @@ -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 } } } } } \ No newline at end of file diff --git a/config/locales/cldr/da_plurals.rb b/config/locales/cldr/da_plurals.rb deleted file mode 100644 index 75d97ee78..000000000 --- a/config/locales/cldr/da_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :da => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/de_plurals.rb b/config/locales/cldr/de_plurals.rb deleted file mode 100644 index a0f157ce8..000000000 --- a/config/locales/cldr/de_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :de => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/el_plurals.rb b/config/locales/cldr/el_plurals.rb deleted file mode 100644 index 5f61405a8..000000000 --- a/config/locales/cldr/el_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :el => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/en_plurals.rb b/config/locales/cldr/en_plurals.rb deleted file mode 100644 index e66a6117f..000000000 --- a/config/locales/cldr/en_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :en => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/eo_plurals.rb b/config/locales/cldr/eo_plurals.rb deleted file mode 100644 index f671f5986..000000000 --- a/config/locales/cldr/eo_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :eo => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/es_plurals.rb b/config/locales/cldr/es_plurals.rb deleted file mode 100644 index abfa8cb18..000000000 --- a/config/locales/cldr/es_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :es => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/eu_plurals.rb b/config/locales/cldr/eu_plurals.rb deleted file mode 100644 index 8f0c5f463..000000000 --- a/config/locales/cldr/eu_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :eu => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/fi_plurals.rb b/config/locales/cldr/fi_plurals.rb deleted file mode 100644 index 51a57d48c..000000000 --- a/config/locales/cldr/fi_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :fi => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/fil_plurals.rb b/config/locales/cldr/fil_plurals.rb deleted file mode 100644 index 48c351baf..000000000 --- a/config/locales/cldr/fil_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :fil => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| [0, 1].include?(n) ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/fr_plurals.rb b/config/locales/cldr/fr_plurals.rb deleted file mode 100644 index eb783f238..000000000 --- a/config/locales/cldr/fr_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :fr => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n && n != 2 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/ga_plurals.rb b/config/locales/cldr/ga_plurals.rb deleted file mode 100644 index dae23db87..000000000 --- a/config/locales/cldr/ga_plurals.rb +++ /dev/null @@ -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 } } } } } \ No newline at end of file diff --git a/config/locales/cldr/gl_plurals.rb b/config/locales/cldr/gl_plurals.rb deleted file mode 100644 index f94440a77..000000000 --- a/config/locales/cldr/gl_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :gl => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/he_plurals.rb b/config/locales/cldr/he_plurals.rb deleted file mode 100644 index 36ea35c26..000000000 --- a/config/locales/cldr/he_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :he => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/hu_plurals.rb b/config/locales/cldr/hu_plurals.rb deleted file mode 100644 index 31ee31fb9..000000000 --- a/config/locales/cldr/hu_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :hu => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/id_plurals.rb b/config/locales/cldr/id_plurals.rb deleted file mode 100644 index 183ae3cac..000000000 --- a/config/locales/cldr/id_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :id => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/is_plurals.rb b/config/locales/cldr/is_plurals.rb deleted file mode 100644 index b9b3fb66e..000000000 --- a/config/locales/cldr/is_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :is => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/it_plurals.rb b/config/locales/cldr/it_plurals.rb deleted file mode 100644 index 4264caa55..000000000 --- a/config/locales/cldr/it_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :it => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/ja_plurals.rb b/config/locales/cldr/ja_plurals.rb deleted file mode 100644 index 31aef4122..000000000 --- a/config/locales/cldr/ja_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :ja => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/ka_plurals.rb b/config/locales/cldr/ka_plurals.rb deleted file mode 100644 index bebe23e2e..000000000 --- a/config/locales/cldr/ka_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :ka => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/ko_plurals.rb b/config/locales/cldr/ko_plurals.rb deleted file mode 100644 index dff9b0543..000000000 --- a/config/locales/cldr/ko_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :ko => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/lt_plurals.rb b/config/locales/cldr/lt_plurals.rb deleted file mode 100644 index f13f5074b..000000000 --- a/config/locales/cldr/lt_plurals.rb +++ /dev/null @@ -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 } } } } } \ No newline at end of file diff --git a/config/locales/cldr/mk_plurals.rb b/config/locales/cldr/mk_plurals.rb deleted file mode 100644 index 4095fa169..000000000 --- a/config/locales/cldr/mk_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :mk => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n % 10 == 1 && n != 11 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/ml_plurals.rb b/config/locales/cldr/ml_plurals.rb deleted file mode 100644 index 2815d104c..000000000 --- a/config/locales/cldr/ml_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :ml => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/ms_plurals.rb b/config/locales/cldr/ms_plurals.rb deleted file mode 100644 index 11a45d103..000000000 --- a/config/locales/cldr/ms_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :ms => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/nb_plurals.rb b/config/locales/cldr/nb_plurals.rb deleted file mode 100644 index 8da3eaefb..000000000 --- a/config/locales/cldr/nb_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :nb => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/nl_plurals.rb b/config/locales/cldr/nl_plurals.rb deleted file mode 100644 index acdb5cdf5..000000000 --- a/config/locales/cldr/nl_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :nl => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/nn_plurals.rb b/config/locales/cldr/nn_plurals.rb deleted file mode 100644 index d13a87120..000000000 --- a/config/locales/cldr/nn_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :nn => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/pa_plurals.rb b/config/locales/cldr/pa_plurals.rb deleted file mode 100644 index a1e3b3bfa..000000000 --- a/config/locales/cldr/pa_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :pa => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/pl_plurals.rb b/config/locales/cldr/pl_plurals.rb deleted file mode 100644 index 56f825eb2..000000000 --- a/config/locales/cldr/pl_plurals.rb +++ /dev/null @@ -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 } } } } } \ No newline at end of file diff --git a/config/locales/cldr/plurals.rb b/config/locales/cldr/plurals.rb new file mode 100644 index 000000000..6cf1b1dd3 --- /dev/null +++ b/config/locales/cldr/plurals.rb @@ -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" }' } } }} \ No newline at end of file diff --git a/config/locales/cldr/ro_plurals.rb b/config/locales/cldr/ro_plurals.rb deleted file mode 100644 index 452acb5cc..000000000 --- a/config/locales/cldr/ro_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :ro => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : n == 0 ? :few : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/ru_plurals.rb b/config/locales/cldr/ru_plurals.rb deleted file mode 100644 index 65156cfba..000000000 --- a/config/locales/cldr/ru_plurals.rb +++ /dev/null @@ -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 } } } } } \ No newline at end of file diff --git a/config/locales/cldr/sk_plurals.rb b/config/locales/cldr/sk_plurals.rb deleted file mode 100644 index 544999796..000000000 --- a/config/locales/cldr/sk_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :sk => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : [2, 3, 4].include?(n) ? :few : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/sl_plurals.rb b/config/locales/cldr/sl_plurals.rb deleted file mode 100644 index 0ccd47170..000000000 --- a/config/locales/cldr/sl_plurals.rb +++ /dev/null @@ -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 } } } } } \ No newline at end of file diff --git a/config/locales/cldr/sq_plurals.rb b/config/locales/cldr/sq_plurals.rb deleted file mode 100644 index c017d9176..000000000 --- a/config/locales/cldr/sq_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :sq => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/sv_plurals.rb b/config/locales/cldr/sv_plurals.rb deleted file mode 100644 index 9bfa12f24..000000000 --- a/config/locales/cldr/sv_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :sv => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/te_plurals.rb b/config/locales/cldr/te_plurals.rb deleted file mode 100644 index ea64fb0c0..000000000 --- a/config/locales/cldr/te_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :te => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/tr_plurals.rb b/config/locales/cldr/tr_plurals.rb deleted file mode 100644 index b0fb316ee..000000000 --- a/config/locales/cldr/tr_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :tr => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/uk_plurals.rb b/config/locales/cldr/uk_plurals.rb deleted file mode 100644 index 22497e611..000000000 --- a/config/locales/cldr/uk_plurals.rb +++ /dev/null @@ -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 } } } } } \ No newline at end of file diff --git a/config/locales/cldr/ur_plurals.rb b/config/locales/cldr/ur_plurals.rb deleted file mode 100644 index 02ff7edf0..000000000 --- a/config/locales/cldr/ur_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :ur => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } } \ No newline at end of file diff --git a/config/locales/cldr/vi_plurals.rb b/config/locales/cldr/vi_plurals.rb deleted file mode 100644 index 9aefb42fc..000000000 --- a/config/locales/cldr/vi_plurals.rb +++ /dev/null @@ -1 +0,0 @@ -{ :vi => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } } \ No newline at end of file diff --git a/public/javascripts/helpers/i18n.js b/public/javascripts/helpers/i18n.js index d01db64f4..63ab758ef 100644 --- a/public/javascripts/helpers/i18n.js +++ b/public/javascripts/helpers/i18n.js @@ -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 || {});