Answer the question
In order to leave comments, you need to log in
How to configure pluralization in Rails I18n?
View:
Locale:<%= t('validate_errors.error', count: 1) %>
validate_errors:
error:
one: "Форма содержит %{count} ошибку"
few: "Форма содержит %{count} ошибки"
many: "Форма содержит %{count} ошибок"
other: "Форма содержит %{count} ошибок"
Answer the question
In order to leave comments, you need to log in
Here is the answer: stackoverflow.com/questions/6166064/i18n-pluralization
You need to set the pluralization rule for the Russian language and everything will work:
2.1.2 :001 > I18n.locale = :ru
=> :ru
2.1.2 :002 > I18n.t 'validate_errors.error', count: 1
=> "Форма содержит 1 ошибку"
2.1.2 :003 > I18n.t 'validate_errors.error', count: 2
=> "Форма содержит 2 ошибки"
2.1.2 :004 > I18n.t 'validate_errors.error', count: 3
=> "Форма содержит 3 ошибки"
2.1.2 :005 > I18n.t 'validate_errors.error', count: 4
=> "Форма содержит 4 ошибки"
2.1.2 :006 > I18n.t 'validate_errors.error', count: 5
=> "Форма содержит 5 ошибок"
2.1.2 :007 > I18n.t 'validate_errors.error', count: 10
=> "Форма содержит 10 ошибок"
2.1.2 :008 > I18n.t 'validate_errors.error', count: 22
=> "Форма содержит 22 ошибки"
2.1.2 :009 > I18n.t 'validate_errors.error', count: 21
=> "Форма содержит 21 ошибку"
Can you imagine how few developers there are in the world? And how many of them are involved in the web? And how much - in rubles? And how many - rails? And how many of them are interested in the comprehensive implementation of their projects? And how many of them care about Russian (not to mention "different")?
There is a gem Russian
about plurals, for example, here it is googled first: rubyclub.com.ua/messages/show/18928-%D1%81%D0%BA%D...
There is native support for pluralization in different languages. guides.rubyonrails.org/i18n.html#pluralization
Try experimenting with the rails version and running the documentation example for yourself.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question