Insert HTML special characters in (i18n) yml

I need to insert a special character in the html file transfer. A symbol is a space, it is necessary that he try to solve another problem.

But it does not work. The code for this character is displayed in the subject line.

To do 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 sent message is as follows: pausa automática disparada

  • "I added only to make this post, but he would not let see here.

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

Where am I going wrong?

+6
source share
2 answers

I think I will succeed. Try "pausa automática\xA0disparada"

Source :

Using one-scalar scalars, you can express any value that does not contain special characters. Shielding for single quotes is not performed, except that a pair of adjacent quotes '' is replaced by a single single quote.

The double quotation mark is the most powerful style and the only style that can express any scalar value. Scanners with double quotes allow shielding. Using the escape sequences \ x ** and \ u **, you can express any ASCII or Unicode character.

And here I found the necessary code

My conclusion:

 # YML title: "Title \xA0 aaa" # console I18n.t('title') => "Title  aaa" 
+8
source

It should work this way. Try checking for typos.

In your example

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

there is an extra ' between   and ; .

+1
source

Source: https://habr.com/ru/post/957119/


All Articles