Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert HTML special characters in (i18n) yml

I need to insert a special character in the html file translation. The character is a space, need it to try to solve another problem.

But it is not working. The code for that character is displayed in the subject of the email.

For this I insert these lines:

pt.yml

subjects:
  ...
  release_auto_pause_triggered_html: "%{project_name} %{release_name} - pausa automática   disparada"

release_mailer.rb

subject = t('subjects.release_auto_pause_triggered_html', project_name: @project.name, release_name: @release.name).html_safe

But the subject of the email sent is as follows: pausa automática disparada

  • The "'" I added just to make this post, but it would not give to see here.

I need to look like this: "pausa automática disparada"

Where am I going wrong?

like image 830
Lorena Bento Avatar asked Oct 31 '13 12:10

Lorena Bento


2 Answers

I think I manage to do it. Try this "pausa automática\xA0disparada"

Source:

Using single-quoted scalars, you may express any value that does not contain special characters. No escaping occurs for single quoted scalars except that a pair of adjacent quotes '' is replaced with a lone single quote '.

Double-quoted is the most powerful style and the only style that can express any scalar value. Double-quoted scalars allow escaping. Using escaping sequences \x** and \u**, you may express any ASCII or Unicode character.

And here I found the necessary code

My output is:

# YML
title: "Title \xA0 aaa"
# console
I18n.t('title')
=> "Title   aaa"
like image 170
gotva Avatar answered Sep 29 '22 13:09

gotva


It should work this way. Try to check for typos.

In your example

"pausa automática&nbsp';disparada""

there is extra ' between &nbsp and ;.

like image 23
ck3g Avatar answered Sep 29 '22 14:09

ck3g