1 # Rails plugin initialization: add default locales to I18n.load_path
 
   2 # - only add locales that are actually used in the application
 
   3 # - prepend locales so that they can be overwritten by the application
 
   5 # We do this after_initialize as the I18n.load_path might be modified
 
   6 # in a config/initializers/initializer.rb
 
   7 class Rails::Initializer #:nodoc:
 
   8   def after_initialize_with_translations_import
 
   9     after_initialize_without_translations_import
 
  10     used_locales = I18n.load_path.map { |f| File.basename(f).gsub(/\.(rb|yml)$/, '') }.uniq
 
  11     files_to_add = Dir[File.join(File.dirname(__FILE__), 'locale', "{#{used_locales.join(',')}}.{rb,yml}")]
 
  12     I18n.load_path.unshift(*files_to_add)
 
  14   alias_method_chain :after_initialize, :translations_import