Added support to dashed locales in templates localization [#1888 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
parent
43c09383ce
commit
24f2e676f7
@ -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]
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
1
actionpack/test/fixtures/test/hello_world.pt-BR.html.erb
vendored
Normal file
1
actionpack/test/fixtures/test/hello_world.pt-BR.html.erb
vendored
Normal file
@ -0,0 +1 @@
|
||||
Ola mundo
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user