Created
September 24, 2013 20:01
-
-
Save lenart/6690435 to your computer and use it in GitHub Desktop.
Rails 3.x I18n pluralization for slovene language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/views/users/index.html.haml | |
%h1 Uporabniki | |
- # 1 uporabnik | |
= t(:user, count: 1) | |
- # 2 uporabnika | |
= t(:user, count: 2) | |
- # 3 uporabniki | |
= t(:user, count: 3) | |
- # 4 uporabniki | |
= t(:user, count: 4) | |
- # 5 uporabnikov | |
= t(:user, count: 5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/pluralization.rb | |
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/locales/plurals.rb | |
# Copied from Rails I18n project | |
{ | |
: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 } } } }, | |
} | |
# Used in gist from Krule - https://gist.github.com/Krule/478347 | |
# Haven't tried it out though | |
# { | |
# :'sl' => { :i18n => { :plural => { :rule => lambda { |n| [1].include?(n % 100) && ![11].include?(n % 100) ? :one : [2].include?(n % 100) && ![12].include?(n % 100) ? :two : [3, 4].include?(n % 100) && ![13, 14].include?(n % 100) ? :few : :other }}}} | |
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/locales/sl.yml | |
sl: | |
user: | |
one: 1 uporabnik | |
two: 2 uporabnika | |
few: "%{count} uporabniki" | |
other: "%{count} uporabnikov" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment