Элькойот Стрикин
unread,Feb 19, 2014, 9:14:42 AM2/19/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ror...@googlegroups.com
Всем привет.
Не могу заставить правильно работать плюрализацию. Работают только :zero, :one и :other. На английский манер, в общем. Дорогие сердцу :few и :many — ни в какую.
Исходные данные:
Rails 4.0.2
в config/initializers создан файл pluralization.rb:
Вариант 1:
require "i18n/backend/pluralization"
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
{
: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 } } } }
}
Вариант 2:
require "i18n/backend/pluralization"
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
в config/locales создан файл ru.yml:
ru:
kids:
zero: ru_zero
one: ru_one
few: ru_few
many: ru_many
other: ru_other
в конфигах(application.rb) прописано
config.i18n.default_locale = :ru
код вывода:
0.upto 15 {|i|
i.to_s + " "
t(:kids, count: i)
}
Вывод:
0 ru_zero
1 ru_one
2 ru_other
3 ru_other
4 ru_other
5 ru_other
6 ru_other
7 ru_other
8 ru_other
9 ru_other
10 ru_other
11 ru_other
12 ru_other
13 ru_other
14 ru_other
15 ru_other
Я не понимат =(