]> git.openstreetmap.org Git - rails.git/blob - config/initializers/i18n.rb
Use a memory cache for sessions when memcache is not configured
[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         ex.entry[:other]
9       end
10     end
11   end
12 end
13
14 module OpenStreetMap
15   module I18n
16     module NormaliseLocales
17       def store_translations(locale, data, options = {})
18         locale = ::I18n::Locale::Tag::Rfc4646.tag(locale).to_s
19
20         super(locale, data, options)
21       end
22     end
23
24     module ValidateLocales
25       def default_fallbacks
26         super.select do |locale|
27           ::I18n.available_locales.include?(locale)
28         end
29       end
30     end
31   end
32 end
33
34 I18n::Backend::Simple.prepend(OpenStreetMap::I18n::NormaliseLocales)
35 I18n::JS::FallbackLocales.prepend(OpenStreetMap::I18n::ValidateLocales)
36
37 I18n::Backend::Simple.include(I18n::Backend::PluralizationFallback)
38 I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
39
40 I18n.fallbacks.map("no" => "nb")
41
42 I18n.enforce_available_locales = false
43
44 Rails.configuration.after_initialize do
45   I18n.available_locales
46 end