-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathrailtie.rb
39 lines (30 loc) · 1007 Bytes
/
railtie.rb
1
2
3
4
5
6
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
37
38
39
require 'rails'
module RailsI18n
class Railtie < ::Rails::Railtie #:nodoc:
config.rails_i18n = RailsI18n
initializer 'rails-i18n' do |app|
RailsI18n::Railtie.instance_eval do
pattern = pattern_from app.config.i18n.available_locales
if app.config.rails_i18n.enabled_modules.empty?
RailsI18n.enabled_modules = Set.new([:locale, :pluralization, :ordinals, :transliteration])
end
RailsI18n.enabled_modules.each do |feature|
add("rails/#{feature}/#{pattern}.{rb,yml}")
end
init_pluralization_module
end
end
protected
def self.add(pattern)
files = Dir[File.join(File.dirname(__FILE__), '../..', pattern)]
I18n.load_path.concat(files)
end
def self.pattern_from(args)
array = Array(args || [])
array.blank? ? '*' : "{#{array.join ','}}"
end
def self.init_pluralization_module
I18n.backend.class.send(:include, I18n::Backend::Pluralization)
end
end
end