]> git.openstreetmap.org Git - rails.git/blob - config/initializers/i18n.rb
Update to rails 4.2.0
[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.has_key?(:other)
8         ex.entry[:other]
9       end
10     end
11   end
12
13   module JS
14     class << self
15       def make_ordered(unordered)
16         ordered = ActiveSupport::OrderedHash.new
17
18         unordered.keys.sort { |a,b| a.to_s <=> b.to_s }.each do |key|
19           value = unordered[key]
20
21           if value.is_a?(Hash)
22             ordered[key] = make_ordered(value)
23           else
24             ordered[key] = value
25           end
26         end
27
28         ordered
29       end
30
31       def filtered_translations_with_order
32         make_ordered(filtered_translations_without_order)
33       end
34
35       alias_method_chain :filtered_translations, :order
36     end
37   end
38 end
39
40 I18n::Backend::Simple.include(I18n::Backend::PluralizationFallback)
41 I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
42
43 I18n.fallbacks.map("no" => "nb")
44
45 I18n.enforce_available_locales = false
46
47 Rails.configuration.after_initialize do
48   I18n.available_locales
49 end