aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorSaimon Moore <saimon@saimonmoore.net>2011-02-01 17:12:51 +0100
committerSantiago Pastorino <santiago@wyeworks.com>2011-02-01 15:36:09 -0200
commitc2aca3ddd78b514d099ddef5afc4cee0dd7d75f2 (patch)
tree08f1a4395a045a05ce2a3fa845a7c7c4edb76fa2 /activesupport/lib
parentb1ca339b53559a71958c02644e329c714037f616 (diff)
downloadrails-c2aca3ddd78b514d099ddef5afc4cee0dd7d75f2.tar.gz
rails-c2aca3ddd78b514d099ddef5afc4cee0dd7d75f2.tar.bz2
rails-c2aca3ddd78b514d099ddef5afc4cee0dd7d75f2.zip
Ensure I18n setup is only executed once if triggered on eager loading [#6353 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/i18n_railtie.rb32
1 files changed, 20 insertions, 12 deletions
diff --git a/activesupport/lib/active_support/i18n_railtie.rb b/activesupport/lib/active_support/i18n_railtie.rb
index 7fdc908bbd..4a9ee5a769 100644
--- a/activesupport/lib/active_support/i18n_railtie.rb
+++ b/activesupport/lib/active_support/i18n_railtie.rb
@@ -24,8 +24,24 @@ module I18n
end
end
- # Proc to set up i18n configuration
- init_load_path = Proc.new do |app|
+ # Set the i18n configuration after initialization since a lot of
+ # configuration is still usually done in application initializers.
+ config.after_initialize do |app|
+ I18n::Railtie.initialize_i18n(app)
+ end
+
+ # Trigger i18n config before any eager loading has happened
+ # so it's ready if any classes require it when eager loaded
+ config.before_eager_load do |app|
+ I18n::Railtie.initialize_i18n(app)
+ end
+
+ protected
+
+ # Setup i18n configuration
+ def self.initialize_i18n(app)
+ return if @i18n_inited
+
fallbacks = app.config.i18n.delete(:fallbacks)
app.config.i18n.each do |setting, value|
@@ -43,17 +59,9 @@ module I18n
reloader.paths.concat I18n.load_path
reloader.execute_if_updated
- end
- # Set the i18n configuration only after initialization since a lot of
- # configuration is still usually done in application initializers.
- config.after_initialize(&init_load_path)
-
- # Trigger i18n config before any eager loading has happened
- # so it's ready if any classes require it when eager loaded
- config.before_eager_load(&init_load_path)
-
- protected
+ @i18n_inited = true
+ end
def self.include_fallbacks_module
I18n.backend.class.send(:include, I18n::Backend::Fallbacks)