Created
July 16, 2010 13:13
-
-
Save Krule/478347 to your computer and use it in GitHub Desktop.
Pluralize using Rails 3 in Slovenian 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
class ApartmentsController < ApplicationController | |
def index | |
@apartments = Apartment.all | |
end | |
end |
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
<%= t(:apartment, :count => @apartments.count) %> |
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
# Pluralization rules for Slovenian language for rails 3 | |
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization) | |
{ | |
:'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
# Example translations for apartment in Slovenian | |
sl: | |
apartment: | |
one: "%{count} stanovanje" | |
two: "%{count} stanovanji" | |
few: "%{count} stanovanja" | |
other: "%{count} stanovanj" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment