Fix i18n locales order test.

This commit is contained in:
José Valim 2010-01-25 22:00:07 +01:00
parent c6104e6514
commit 1177a40e68
2 changed files with 14 additions and 8 deletions

View File

@ -33,6 +33,7 @@ module I18n
railtie_name :i18n
# Initialize I18n load paths to an array
config.i18n.engines_load_path = []
config.i18n.load_path = []
initializer :initialize_i18n do
@ -47,7 +48,10 @@ module I18n
# the load_path which should be appended to what's already set instead of overwritten.
config.after_initialize do |app|
app.config.i18n.each do |setting, value|
if setting == :load_path
case setting
when :engines_load_path
app.config.i18n.load_path.unshift(*value)
when :load_path
I18n.load_path += value
else
I18n.send("#{setting}=", value)

View File

@ -57,12 +57,12 @@ module Rails
# Set the paths from which Rails will automatically load source files,
# and the load_once paths.
initializer :set_autoload_paths do |app|
ActiveSupport::Dependencies.load_paths.concat(config.load_paths)
ActiveSupport::Dependencies.load_paths.unshift(*config.load_paths)
if reloadable?(app)
ActiveSupport::Dependencies.load_once_paths.concat(config.load_once_paths)
ActiveSupport::Dependencies.load_once_paths.unshift(*config.load_once_paths)
else
ActiveSupport::Dependencies.load_once_paths.concat(config.load_paths)
ActiveSupport::Dependencies.load_once_paths.unshift(*config.load_paths)
end
# Freeze so future modifications will fail rather than do nothing mysteriously
@ -86,18 +86,20 @@ module Rails
end
end
# I18n load paths are a special case since the ones added
# later have higher priority.
initializer :add_locales do
config.i18n.load_path.unshift(*paths.config.locales.to_a)
config.i18n.engines_load_path.concat(paths.config.locales.to_a)
end
initializer :add_view_paths do
views = paths.app.views.to_a
ActionController::Base.view_paths.concat(views) if defined?(ActionController)
ActionMailer::Base.view_paths.concat(views) if defined?(ActionMailer)
ActionController::Base.view_paths.unshift(*views) if defined?(ActionController)
ActionMailer::Base.view_paths.unshift(*views) if defined?(ActionMailer)
end
initializer :add_metals do
Rails::Rack::Metal.paths.concat(paths.app.metals.to_a)
Rails::Rack::Metal.paths.unshift(*paths.app.metals.to_a)
end
initializer :load_application_initializers do