aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
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/test
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/test')
-rw-r--r--railties/test/fixtures/plugins/engines/engine/config/locales/en.yml2
-rw-r--r--railties/test/initializer_test.rb1
-rw-r--r--railties/test/plugin_loader_test.rb8
3 files changed, 11 insertions, 0 deletions
diff --git a/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml b/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
new file mode 100644
index 0000000000..641a7e035c
--- /dev/null
+++ b/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
@@ -0,0 +1,2 @@
+en:
+ hello: "Hello from Engine"
diff --git a/railties/test/initializer_test.rb b/railties/test/initializer_test.rb
index 1fecd62995..5bbd060962 100644
--- a/railties/test/initializer_test.rb
+++ b/railties/test/initializer_test.rb
@@ -406,6 +406,7 @@ class InitializerSetupI18nTests < Test::Unit::TestCase
File.expand_path(File.dirname(__FILE__) + "/../../actionpack/lib/action_view/locale/en.yml"),
File.expand_path(File.dirname(__FILE__) + "/../../activemodel/lib/active_model/locale/en.yml"),
File.expand_path(File.dirname(__FILE__) + "/../../activerecord/lib/active_record/locale/en.yml"),
+ File.expand_path(File.dirname(__FILE__) + "/../../railties/test/fixtures/plugins/engines/engine/config/locales/en.yml"),
"my/test/locale.yml",
"my/other/locale.yml" ], I18n.load_path.collect { |path| path =~ /\.\./ ? File.expand_path(path) : path }
end
diff --git a/railties/test/plugin_loader_test.rb b/railties/test/plugin_loader_test.rb
index 873e000222..99301347b6 100644
--- a/railties/test/plugin_loader_test.rb
+++ b/railties/test/plugin_loader_test.rb
@@ -156,6 +156,14 @@ class TestPluginLoader < Test::Unit::TestCase
plugin_load_paths.each { |path| assert $LOAD_PATH.include?(path) }
end
+ def test_should_add_locale_files_to_I18n_load_path
+ only_load_the_following_plugins! [:engine]
+
+ @loader.send :add_engine_locales
+
+ assert I18n.load_path.include?(File.join(plugin_fixture_path('engines/engine'), 'config', 'locales', 'en.yml'))
+ end
+
private
def reset_load_path!