Flo Rahl
Flo Rahl

Reputation: 1054

I18n special characters in page title

I'm coding a rails app, and I have a problem with the title's page :

In my config/locales/fr.yml I have this : fr:product:edit: "Modification de l'objet"

And in my /app/views/products/edit.html.erb I have this : <title><%= t('product.edit') %></title>

And when I render the page, it gives me this : Modification de l&#39;objet.

Do you know what's wrong with it ?

I tried to add <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> in the head of my HTML, or this but it didn't worked for me...

Upvotes: 1

Views: 2154

Answers (2)

aherve
aherve

Reputation: 4070

You can use <%= raw(I18n.t('product.edit')) %> to avoid this. Be aware though, that the code won't be escaped. When using raw you have to be sure there's no way to inject malicious code in the string.

Upvotes: 1

AltF4_
AltF4_

Reputation: 2470

I think I can tell you where l&#'39 is coming from... Hopefuly then you can find a solution on how to fix it.

Open up notepad and holddown the Alt key and press 39 see what character appears ??

You notice you get the ' character when you type that number so after compling you code seems to look at l'objet as l And #39

So I think there is as you are poinitg out some sort language issues and the characters are represented. You might be able to reverse this to solve your problem.

Sorry this is all I had.

Upvotes: 0

Related Questions