]> git.openstreetmap.org Git - rails.git/blob - config/initializers/i18n.rb
Merge remote-tracking branch 'upstream/pull/2196'
[rails.git] / config / initializers / i18n.rb
1 module I18n
2   module Backend
3     module PluralizationFallback
4       def pluralize(locale, entry, count)
5         super
6       rescue InvalidPluralizationData => ex
7         raise ex unless ex.entry.key?(:other)
8
9         ex.entry[:other]
10       end
11     end
12   end
13 end
14
15 module OpenStreetMap
16   module I18n
17     module NormaliseLocales
18       def store_translations(locale, data, options = {})
19         locale = ::I18n::Locale::Tag::Rfc4646.tag(locale).to_s
20
21         super(locale, data, options)
22       end
23     end
24
25     module ValidateLocales
26       def default_fallbacks
27         super.select do |locale|
28           ::I18n.available_locales.include?(locale)
29         end
30       end
31     end
32   end
33 end
34
35 I18n::Backend::Simple.prepend(OpenStreetMap::I18n::NormaliseLocales)
36 I18n::JS::FallbackLocales.prepend(OpenStreetMap::I18n::ValidateLocales)
37
38 I18n::Backend::Simple.include(I18n::Backend::PluralizationFallback)
39 I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
40
41 I18n.fallbacks.map("no" => "nb")
42
43 I18n.enforce_available_locales = false
44
45 Rails.configuration.after_initialize do
46   I18n.available_locales
47 end