This project is archived and is in readonly mode.
Wrong Content-Type when using localized templates
Reported by Nicolas Blanco | February 2nd, 2009 @ 10:20 PM
Hi,
when I use localized template like : index.fr.html.erb, the Content-Type header sent by the server becomes "fr.html; charset=utf-8" instead of the standard "text/html; charset=utf-8".
Because of this problem, my browser (Firefox 3) sets a bad character decoder (ISO instead of UTF-8) and my views are broken.
Comments and changes to this ticket
-
Nicolas Blanco February 3rd, 2009 @ 10:07 AM
- Tag set to 2.3, i18n, localization, templates
OK.
More information : the bad Content-Type is only sent when the locale is not properly loaded/valid (for example in a new Rails application, you set the locale to :fr in the environment.rb file but you don't put a fr.yml file).
But IMHO, the Content-Type sent by Rails should be valid even if the locale is not valid/loaded.
-
josh February 3rd, 2009 @ 11:24 PM
- State changed from new to wontfix
- Milestone cleared.
You can register more extensions without adding more configs to locales with
I18n.backend.store_translations 'fr', {}
-
hkstar February 17th, 2009 @ 11:58 AM
Strongly disagree with above "wontfix". The current behaviour is to half-work, with an incorrect content-type, causing insidious and confusing hard-to-troubleshoot errors. I spent a couple of hours tracking this nasty bug down before finally arriving here.
The "fix" is undocumented and obscure. The localised templates otherwise work, just silently include a completely wrong content-type. What excuse is there for that kind of hideous bug?
This ticket needs to be re-opened immediately.
-
Eloy Duran February 17th, 2009 @ 12:30 PM
Hmm, we had this issue too, but while I was investigating the issue it was fixed, for at least our case, in edge by another commit.
@hkstar: I would suggest you write some failing unit tests for Template#split, which is most probably where the problem lies.
-
Steven Bedrick August 28th, 2009 @ 01:43 AM
I also disagree with the "wontfix"- I've just run into this bug, and I most definitely have my locale loaded and set correctly. Other parts of the Rails I18n system are working fine, strings are being loaded from my locale file on other templates, etc... but anything that tries to load a localized view displays the above-described behavior. The correct (i.e., localized) view loads, is rendered, and is then sent down to the browser with a content-type of "#{locale}.html".
-
Kris Leech February 18th, 2010 @ 12:05 PM
This also happens if you use a template filename such as edit.default.html.erb, the content-type in this case is set to edit.html, not text/html.
Changing to edit_default.html.erb or manually setting the correct content-type header prevents this problem but imposes a naming scheme on your templates or additional work.
Rails 2.3.5
-
Michael Reinsch July 14th, 2010 @ 03:02 AM
- Importance changed from to
With rails 2.3.8, I don't seem to be able to fix this issue with the workaround given.
As far as I can tell, the I18n backend is correctly initialized (dumping it indeed shows that :ja has translations). But still, the content type for a "support.ja.html.haml" template is set to "ja.html; charset=utf-8".
-
James Le Cuirot July 14th, 2010 @ 08:46 AM
It works for me with a more recent 2-3-stable but my workaround is to actually create empty locale files like this.
ja: activerecord:
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>