Browse files

Added support to dashed locales in templates localization [#1888 stat…

…e:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
1 parent 43c0938 commit 24f2e676f700b8a387c6f4c27acf172658cd7863 @josevalim josevalim committed with josh Feb 6, 2009
View
2 actionpack/lib/action_view/template.rb
@@ -236,7 +236,7 @@ def split(file)
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]
View
1 actionpack/test/abstract_unit.rb
@@ -34,6 +34,7 @@
# 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')
View
7 actionpack/test/controller/rescue_test.rb
@@ -198,13 +198,6 @@ def test_rescue_action_in_public_otherwise
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
View
1 actionpack/test/fixtures/test/hello_world.pt-BR.html.erb
@@ -0,0 +1 @@
+Ola mundo
View
9 actionpack/test/template/render_test.rb
@@ -10,6 +10,7 @@ def setup_view(paths)
# 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 @@ def test_render_file_with_localization
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

0 comments on commit 24f2e67

Please sign in to comment.