Commit c5654a43 authored by Jonne Haß's avatar Jonne Haß

do proper pluralization for JS

parent 9ecc3005
......@@ -16,26 +16,6 @@ module ApplicationHelper
"javascript:(function(){f='#{AppConfig[:pod_url]}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&notes='+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
\ 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
{ :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
{ :bg => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :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
{ :ca => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :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
{ :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
{ :da => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :de => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :el => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :en => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :eo => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :es => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :eu => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :fi => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :fil => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| [0, 1].include?(n) ? :one : :other } } } } }
\ No newline at end of file
{ :fr => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n && n != 2 ? :one : :other } } } } }
\ No newline at end of file
{ :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
{ :gl => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :he => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :hu => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
\ No newline at end of file
{ :id => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
\ No newline at end of file
{ :is => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :it => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :ja => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
\ No newline at end of file
{ :ka => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
\ No newline at end of file
{ :ko => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
\ No newline at end of file
{ :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
{ :mk => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n % 10 == 1 && n != 11 ? :one : :other } } } } }
\ No newline at end of file
{ :ml => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :ms => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
\ No newline at end of file
{ :nb => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :nl => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :nn => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :pa => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :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
This diff is collapsed.
{ :ro => { :i18n => {:plural => { :keys => [:one, :few, :other], :rule => lambda { |n| n == 1 ? :one : n == 0 ? :few : :other } } } } }
\ No newline at end of file
{ :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
{ :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
{ :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
{ :sq => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :sv => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :te => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :tr => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
\ No newline at end of file
{ :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
{ :ur => { :i18n => {:plural => { :keys => [:one, :other], :rule => lambda { |n| n == 1 ? :one : :other } } } } }
\ No newline at end of file
{ :vi => { :i18n => {:plural => { :keys => [:other], :rule => lambda { |n| :other } } } } }
\ No newline at end of file
......@@ -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 || {});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment