aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/plugin
diff options
context:
space:
mode:
authorAntonio Tapiador del Dujo <atapiador@dit.upm.es>2009-03-24 14:49:47 +0100
committerJeremy Kemper <jeremy@bitsweat.net>2009-08-30 13:36:22 -0700
commitcf4846c6ae991143afaef987a63c3ad9a3a2546b (patch)
tree79dcc28149ac974aab94b48ae429aa6071d39afb /railties/lib/rails/plugin
parent0efedf2a30a12cdaa261556e3684c630690afe0f (diff)
downloadrails-cf4846c6ae991143afaef987a63c3ad9a3a2546b.tar.gz
rails-cf4846c6ae991143afaef987a63c3ad9a3a2546b.tar.bz2
rails-cf4846c6ae991143afaef987a63c3ad9a3a2546b.zip
I18n support for plugins
Rails will now automatically add locale files found in any engine's locale directory to the I18n.load_path (i.e. files that match the glob pattern "config/locales/**/*.{rb,yml}" relative to engine directories). [#2325 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'railties/lib/rails/plugin')
-rw-r--r--railties/lib/rails/plugin/loader.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/railties/lib/rails/plugin/loader.rb b/railties/lib/rails/plugin/loader.rb
index 7ea9c7c0f3..9e2c3c7b03 100644
--- a/railties/lib/rails/plugin/loader.rb
+++ b/railties/lib/rails/plugin/loader.rb
@@ -73,6 +73,7 @@ module Rails
def configure_engines
if engines.any?
add_engine_routing_configurations
+ add_engine_locales
add_engine_controller_paths
add_engine_view_paths
end
@@ -84,6 +85,12 @@ module Rails
end
end
+ def add_engine_locales
+ # reverse it such that the last engine can overwrite translations from the first, like with routes
+ locale_files = engines.select(&:localized?).collect(&:locale_files).reverse.flatten
+ I18n.load_path += locale_files - I18n.load_path
+ end
+
def add_engine_controller_paths
ActionController::Routing.controller_paths += engines.collect {|engine| engine.controller_path }
end