From 16e26de2c5edd37113f13e46766f6e7ac84a17b2 Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Thu, 26 Aug 2021 17:38:06 +0300 Subject: [PATCH] Remove the custom pluralisation rules in favor of rails_i18n and fix the RU language file a bit. --- config/initializers/i18n-config.rb | 37 ------------------------------ config/locales/ru.yml | 2 ++ 2 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 config/initializers/i18n-config.rb diff --git a/config/initializers/i18n-config.rb b/config/initializers/i18n-config.rb deleted file mode 100644 index a951eeac..00000000 --- a/config/initializers/i18n-config.rb +++ /dev/null @@ -1,37 +0,0 @@ -module I18n::Backend::Pluralization - # rules taken from : http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html - def pluralize(locale, entry, n) - return entry unless entry.is_a?(Hash) && n - if n == 0 && entry.has_key?(:zero) - key = :zero - else - key = case locale - when :pl # Polish - n==1 ? :one : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? :few : :other - when :cs, :sk # Czech, Slovak - n==1 ? :one : (n>=2 && n<=4) ? :few : :other - when :lt # Lithuanian - n%10==1 && n%100!=11 ? :one : n%10>=2 && (n%100<10 || n%100>=20) ? :few : :other - when :lv # Latvian - n%10==1 && n%100!=11 ? :one : n != 0 ? :few : :other - when :ru, :uk, :sr, :hr # Russian, Ukrainian, Serbian, Croatian - n%10==1 && n%100!=11 ? :one : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? :few : :other - when :sl # Slovenian - n%100==1 ? :one : n%100==2 ? :few : n%100==3 || n%100==4 ? :many : :other - when :ro # Romanian - n==1 ? :one : (n==0 || (n%100 > 0 && n%100 < 20)) ? :few : :other - when :gd # Gaeilge - n==1 ? :one : n==2 ? :two : :other; - # add another language if you like... - else - n==1 ? :one : :other # default :en - end - end - key = :other if key == :few && !entry.has_key?(key) #fallback to :other if :few is missing - raise InvalidPluralizationData.new(entry, n) unless entry.has_key?(key) - entry[key] - end -end - -I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization) -I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 43681c8a..ba9a53b1 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -102,6 +102,7 @@ ru: one: действий few: действие many: действия + other: действия add: Добавить ajaxError: От сервера была получена ошибка back: Назад @@ -1079,6 +1080,7 @@ ru: one: Отложить на 1 день few: Отложить на %{count} дня many: Отложить на %{count} дней + other: Отложить на %{count} дней deferred_actions_with: Отложенные действия с меткой '%{tag_name}' deferred_pending_actions: Отложенные/ожидающие действия deferred_tasks_title: TRACKS::Отложенные