lib/rails_i18n/railtie.rb in rails-i18n-0.4.0 vs lib/rails_i18n/railtie.rb in rails-i18n-0.5.0.beta1
- old
+ new
@@ -1,13 +1,26 @@
require 'rails'
module RailsI18n
class Railtie < ::Rails::Railtie #:nodoc:
- initializer 'rails-i18n' do |app|
- I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__) + '/../../rails/locale'), '*.{rb,yml}')]
- if defined? ::WillPaginate
- I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__) + '/../../will_paginate'), '*.{rb,yml}')]
+ initializer 'rails-i18n' do
+ RailsI18n::Railtie.instance_eval do
+ add('rails/locale/*.yml')
+ add('rails/pluralization/*.rb')
+ add('rails/transliteration/*.{rb,yml}')
+
+ init_pluralization_module
end
- I18n.load_path.flatten!
+ end
+
+ protected
+
+ def self.add(pattern)
+ files = Dir[File.join(File.dirname(__FILE__), '../..', pattern)]
+ I18n.load_path.concat(files)
+ end
+
+ def self.init_pluralization_module
+ I18n.backend.class.send(:include, I18n::Backend::Pluralization)
end
end
end