Created
January 9, 2009 18:49
-
-
Save Baael/45217 to your computer and use it in GitHub Desktop.
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
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