html - 在 (i18n) yml 中插入 HTML 特殊字符

标签 html ruby-on-rails ruby ruby-on-rails-3

我需要在 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/

相关文章:

ruby-on-rails - rails : how to exclude post requests for a before_action in the application controller

Ruby-获取 xml 节点值

ruby-on-rails - 一个 Rails 应用程序中存在两个独立命名空间的 Gemfile?

ruby - 如何向 RDoc 添加页面?

html - css 中的 Body div 无法正确读取属性

javascript - 文本区域中的行高(IE7)

jquery - 在移动设备上关闭滚动条外的滚动

javascript - AudioContext createMediaElementSource 来自从 blob 中获取数据的视频

ruby-on-rails - 在rails应用程序中发送AJAX Post Jquery

ruby-on-rails - Ruby on Rails 的广告/横幅管理/轮播?