Skip to content

Instantly share code, notes, and snippets.

@Baael
Created January 9, 2009 18:49
Show Gist options
  • Save Baael/45217 to your computer and use it in GitHub Desktop.
Save Baael/45217 to your computer and use it in GitHub Desktop.
module I18n
module Backend
class PolishPluralization < Simple
def pluralize(locale, entry, count)
return entry unless entry.is_a?(Hash) and count
case locale
when 'pl'
key = :zero if count == 0 && entry.has_key?(:zero)
key = :one if count==1 && count%100!=11
key ||=((2..4).include?(count%10) && !(12..14).include?(count%100))? :few : :other
else
key = :zero if count == 0 && entry.has_key?(:zero)
key ||= count == 1 ? :one : :other
end
raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key)
entry[key]
end
end
end
end
I18n.backend = I18n::Backend::PolishPluralization.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment