]> git.openstreetmap.org Git - rails.git/blob - config/initializers/i18n.rb
Drop locale fallback from no to nb
[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 => e
7         raise e unless e.entry.key?(:other)
8
9         e.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
22       end
23     end
24   end
25 end
26
27 I18n::Backend::Simple.prepend(OpenStreetMap::I18n::NormaliseLocales)
28
29 I18n::Backend::Simple.include(I18n::Backend::PluralizationFallback)
30 I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
31
32 I18n.enforce_available_locales = false
33
34 if Rails.env.test?
35   I18n.exception_handler = proc do |exception|
36     raise exception.to_exception
37   end
38 end
39
40 Rails.configuration.after_initialize do
41   I18n.available_locales
42 end