mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #44174 from jguecaimburu/add_lowdash_support_to_path_parser_locale_regex
Add support to locales with lowdash in Resolver::PathParser
This commit is contained in:
commit
139ef8a0bc
4 changed files with 19 additions and 1 deletions
|
@ -45,4 +45,11 @@ class LocalizedTemplatesTest < ActionController::TestCase
|
|||
assert_equal "Ciao Mondo", @response.body
|
||||
assert_equal "text/html", @response.media_type
|
||||
end
|
||||
|
||||
def test_use_locale_with_lowdash
|
||||
I18n.locale = :"de_AT"
|
||||
|
||||
get :hello_world
|
||||
assert_equal "Guten Morgen", @response.body
|
||||
end
|
||||
end
|
||||
|
|
1
actionpack/test/fixtures/localized/hello_world.de_AT.html
vendored
Normal file
1
actionpack/test/fixtures/localized/hello_world.de_AT.html
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Guten Morgen
|
|
@ -19,7 +19,7 @@ module ActionView
|
|||
def build_path_regex
|
||||
handlers = Template::Handlers.extensions.map { |x| Regexp.escape(x) }.join("|")
|
||||
formats = Template::Types.symbols.map { |x| Regexp.escape(x) }.join("|")
|
||||
locales = "[a-z]{2}(?:-[A-Z]{2})?"
|
||||
locales = "[a-z]{2}(?:[-_][A-Z]{2})?"
|
||||
variants = "[^.]*"
|
||||
|
||||
%r{
|
||||
|
|
|
@ -232,4 +232,14 @@ module ResolverSharedTests
|
|||
|
||||
assert_empty context.find_all("hello_world.html", "test", false, [], {})
|
||||
end
|
||||
|
||||
def test_finds_template_with_lowdash_format
|
||||
with_file "test/hello_world.es_AR.text.erb", "Texto simple!"
|
||||
|
||||
es_ar = context.find_all("hello_world", "test", false, [], locale: [:es_AR])
|
||||
|
||||
assert_equal 1, es_ar.size
|
||||
|
||||
assert_equal "Texto simple!", es_ar[0].source
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue