7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/rich/pluralization/engine.rb', line 7
def init(test_class = nil)
if test_class
test_locale = test_class.name.match(/(Rich\:\:Pluralization\:\:Test\:\:Locales\:\:)(\w+)/).captures[1].downcase.to_sym
I18n.load_path = [File.join(File.dirname(__FILE__), "..", "..", "..", "locales", "#{test_locale}.yml")]
else
I18n.load_path += Dir[File.join(File.dirname(__FILE__), "..", "..", "..", "locales", "*.yml")]
end
I18n.backend.reload!
Rich::Pluralization::Inflector.inflections.reset_attrs if test_class
initial_locale = I18n.locale
I18n.backend.available_locales.each do |locale|
I18n.locale = locale
Rich::Pluralization::Inflector.inflections locale do |inflections|
(I18n.t! "e9s" rescue []).each do |type, entries|
entries.each do |inflection|
inflections.send *[type, inflection].flatten
end
end
end
end
I18n.locale = initial_locale
test_locale
end
|