Add a fallback to :other for i18n

In most cases, translations don't supply `:few` even though the language
may support the construct. Instead of the app blowing up if the
translation for `:few` doesn't exist, fall back to `:other` instead.
This commit is contained in:
Matt Rogers 2016-08-20 14:43:42 -05:00
parent bd0598ef64
commit 0511ea3a3a

View file

@ -27,10 +27,11 @@ module I18n::Backend::Pluralization
n==1 ? :one : :other # default :en
end
end
key = :other if key == :few && !entry.has_key?(key) #fallback to :other if :few is missing
raise InvalidPluralizationData.new(entry, n) unless entry.has_key?(key)
entry[key]
end
end
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)