Skip to content

Instantly share code, notes, and snippets.

@Krule
Created July 16, 2010 13:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Krule/478347 to your computer and use it in GitHub Desktop.
Save Krule/478347 to your computer and use it in GitHub Desktop.
Pluralize using Rails 3 in Slovenian language
class ApartmentsController < ApplicationController
def index
@apartments = Apartment.all
end
end
<%= t(:apartment, :count => @apartments.count) %>
# 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 }}}}
}
# 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