This project is archived and is in readonly mode.
Localized templates does not work with "pt-BR" or "en-US" as locale
Reported by José Valim | February 5th, 2009 @ 06:36 PM
Localized templates is not working when the locale contains a dash "-" (for example index.pt-BR.html.erb and show.en-US.html.erb).
The reason of it is on rails/actionpack/lib/action_view/template.rb.
On line 239 we see the regexp that process our extensions in our view path is
m = extensions.match(/^(\w+)?\.?(\w+)?\.?(\w+)?\.?/)
The first parenthesis, which is the one that checks for the locale does not accepts dash -.
A working regexp would be:
/^(\w+\-?\w*)?\.?(\w+)?\.?(\w+)?\.?/
And we can see it working on Rubular:
Comments and changes to this ticket
-
José Valim February 5th, 2009 @ 09:58 PM
- Assigned user set to josh
-
josh February 5th, 2009 @ 10:16 PM
- State changed from new to open
- Milestone cleared.
Just want to make sure, I18n supports dashed locales? If so, we should support this.
Can you make a failing test case to go along with this and I'll get it in 2.3
-
José Valim February 5th, 2009 @ 10:22 PM
Yes, I18n supports dashed locales. Remember that at first, the default locale would even be "en-US"?
I will make a failing test case and a patch. :)
-
Sven Fuchs February 5th, 2009 @ 11:28 PM
Yup, it does. Just for the record that's RFC4646 (http://tools.ietf.org/html/rfc46....1). Picked that one because it seemed like the best match.
José, thanks for taking care of this!
-
José Valim February 6th, 2009 @ 09:17 AM
Patch attached!
Josh, we are calling I18n.reload! to add locales in both rescue_test.rb and render_test.rb. This is not needed, because we are already adding the locales in abstract_unit.rb.
I just didn't want to remove it, since it's not the scope of this patch, but I'm going to attach other soon.
@Sven, glad to help! :)
-
José Valim February 6th, 2009 @ 09:37 AM
Josh, attached another patch "simplifying_rescue_tests.diff" and it should be applied after the first I sent.
I removed such lines and everything still passes over here, but I would recommend you to check if it also passes on your machine.
Regards!
-
Repository February 7th, 2009 @ 05:29 AM
- State changed from open to resolved
(from [24f2e676f700b8a387c6f4c27acf172658cd7863]) Added support to dashed locales in templates localization [#1888 state:resolved] Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 1888 Localized templates does not work with "pt-BR" or "en-US" as locale (from [24f2e676f700b8a387c6f4c27acf172658cd7863]) Added s...