我需要在 html 文件翻译中插入一个特殊字符。 该字符是一个空格,需要它来尝试解决另一个问题。
但它不起作用。该字符的代码显示在电子邮件的主题中。
为此我插入了这些行:
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
但是发送的邮件主题如下:pausa automática disparada
- 我添加的“'”只是为了发这个帖子,但在这里看不到。
我需要看起来像这样:“pausa automática disparada”
我哪里错了?
最佳答案
我想我做到了。试试这个 "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.
和here我找到了必要的代码
我的输出是:
# YML
title: "Title \xA0 aaa"
# console
I18n.t('title')
=> "Title aaa"
关于html - 在 (i18n) yml 中插入 HTML 特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19706925/