Monkey patch in an upstream fix for I18n::Backend::Fallbacks
[rails.git] / config / initializers / i18n.rb
1 module I18n
2   module Backend
3     class Simple
4       module Implementation
5         protected
6         alias_method :old_init_translations, :init_translations
7       
8         def init_translations
9           old_init_translations
10
11           store_translations(:nb, translations[:no])
12           translations[:no] = translations[:nb]
13
14           @skip_syntax_deprecation = true
15         end
16       end
17     end
18
19     module Fallbacks
20       def find_first_string_or_lambda_default(defaults)
21         defaults.each_with_index { |default, ix| return ix if default && !default.is_a?(Symbol) }
22         nil
23       end
24     end
25
26     module PluralizationFallback
27       def pluralize(locale, entry, count)
28         super
29       rescue InvalidPluralizationData => ex
30         raise ex unless ex.entry.has_key?(:other)
31         ex.entry[:other]
32       end
33     end
34   end
35 end
36
37 I18n::Backend::Simple.include(I18n::Backend::Pluralization)
38 I18n::Backend::Simple.include(I18n::Backend::PluralizationFallback)
39 I18n.load_path << "#{Rails.root}/config/pluralizers.rb"
40
41 I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
42
43 Rails.configuration.after_initialize do
44   I18n.reload!
45 end