【问题标题】:Rails i18n shows translated text surrounded by [" "]Rails i18n 显示被 [" "] 包围的翻译文本
【发布时间】:2011-05-31 19:18:49
【问题描述】:

当尝试在 rails 中使用 i18n 时,我得到以下不想要的输出。

翻译后的文本被[" "]包围,例如:

hello: "Hello"

<%= t(:hello) %>

显示为 ["Hello"]

知道为什么会这样吗?

更新

en.yml

en:

hello: "Hello"

用法

<%= t(:hello) %>

它...

【问题讨论】:

  • 你能显示更多翻译所在的代码行吗?
  • 例如,<%= t(:hello).to_a.inspect %> 将显示 ["hello"]。检查您的实际代码中是否有类似的东西。向我们展示 yml 文件中的实际行以及 <%= .. %> 代码!

标签: ruby-on-rails-3 internationalization


【解决方案1】:

我可能是错的,但你可以尝试像这样使用它吗:

<%= t('hello') %>

这就是我毫无问题地使用它的方式:)

【讨论】:

  • 实际上它可以工作,是我的设置搞砸了 - 谢谢
猜你喜欢
  • 2015-04-20
  • 2017-11-11
  • 1970-01-01
  • 2017-02-27
  • 1970-01-01
  • 2011-02-02
  • 1970-01-01
  • 1970-01-01
  • 2017-01-16
相关资源
最近更新 更多