aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-02-06 23:23:50 -0600
committerJoshua Peek <josh@joshpeek.com>2009-02-06 23:23:50 -0600
commit24f2e676f700b8a387c6f4c27acf172658cd7863 (patch)
tree5b664014391c3e8a5828e02492cea72d356358bc /actionpack
parent43c09383cefbc3b62e9b124792fb0d0278689d2b (diff)
downloadrails-24f2e676f700b8a387c6f4c27acf172658cd7863.tar.gz
rails-24f2e676f700b8a387c6f4c27acf172658cd7863.tar.bz2
rails-24f2e676f700b8a387c6f4c27acf172658cd7863.zip
Added support to dashed locales in templates localization [#1888 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/template.rb2
-rw-r--r--actionpack/test/abstract_unit.rb1
-rw-r--r--actionpack/test/controller/rescue_test.rb7
-rw-r--r--actionpack/test/fixtures/test/hello_world.pt-BR.html.erb1
-rw-r--r--actionpack/test/template/render_test.rb9
5 files changed, 12 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index 553158b82a..a0ae33caf0 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -236,7 +236,7 @@ module ActionView #:nodoc:
format = nil
extension = nil
- if m = extensions.match(/^(\w+)?\.?(\w+)?\.?(\w+)?\.?/)
+ if m = extensions.match(/^([\w-]+)?\.?(\w+)?\.?(\w+)?\.?/)
if valid_locale?(m[1]) && m[2] && valid_extension?(m[3]) # All three
locale = m[1]
format = m[2]
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index c3717a60b8..07bd7ba71d 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -34,6 +34,7 @@ ActionController::Base.session_store = nil
# Register danish language for testing
I18n.backend.store_translations 'da', {}
+I18n.backend.store_translations 'pt-BR', {}
ORIGINAL_LOCALES = I18n.available_locales.map(&:to_s).sort
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb
index d7c9499157..5709f37e05 100644
--- a/actionpack/test/controller/rescue_test.rb
+++ b/actionpack/test/controller/rescue_test.rb
@@ -198,13 +198,6 @@ class RescueControllerTest < ActionController::TestCase
end
def test_rescue_action_in_public_with_localized_error_file
- # Reload and register danish language for testing
- I18n.reload!
- I18n.backend.store_translations 'da', {}
-
- # Ensure original are still the same since we are reindexing view paths
- assert_equal ORIGINAL_LOCALES, I18n.available_locales.map(&:to_s).sort
-
# Change locale
old_locale = I18n.locale
I18n.locale = :da
diff --git a/actionpack/test/fixtures/test/hello_world.pt-BR.html.erb b/actionpack/test/fixtures/test/hello_world.pt-BR.html.erb
new file mode 100644
index 0000000000..773b3c8c6e
--- /dev/null
+++ b/actionpack/test/fixtures/test/hello_world.pt-BR.html.erb
@@ -0,0 +1 @@
+Ola mundo \ No newline at end of file
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index 2caf4e8fe4..5586434cb6 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -10,6 +10,7 @@ module RenderTestCases
# Reload and register danish language for testing
I18n.reload!
I18n.backend.store_translations 'da', {}
+ I18n.backend.store_translations 'pt-BR', {}
# Ensure original are still the same since we are reindexing view paths
assert_equal ORIGINAL_LOCALES, I18n.available_locales.map(&:to_s).sort
@@ -35,6 +36,14 @@ module RenderTestCases
I18n.locale = old_locale
end
+ def test_render_file_with_dashed_locale
+ old_locale = I18n.locale
+ I18n.locale = :"pt-BR"
+ assert_equal "Ola mundo", @view.render(:file => "test/hello_world")
+ ensure
+ I18n.locale = old_locale
+ end
+
def test_render_file_at_top_level
assert_equal 'Elastica', @view.render(:file => '/shared')
end