This project is archived and is in readonly mode.

#1888 ✓resolved
José Valim

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:

http://www.rubular.com/regexes/6077

Comments and changes to this ticket

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

Referenced by

Pages