R18 I18n没有替换变量

时间:2015-05-08 00:21:57

标签: ruby-on-rails internationalization i18n-gem

我的部分翻译遇到了问题,我的翻译没有用我提供的文字替换,而是直接输出翻译。

示例翻译

formats:
   view_all_other: "View all other %{format_title}"

使用示例(HAML)

= link_to t('formats.view_all_other', format_title: @format.title.downcase), "/#{@format.to_param}/all"

输出什么

enter image description here

我一直在网上搜索,但我还没有见过有这个问题的人。这是我第一次使用i18n,但看起来我没有设置错误,其他翻译工作正常(包括可变替换的翻译)。

2 个答案:

答案 0 :(得分:1)

您的翻译应该是语言层次结构。让我们看看en.yml,然后翻译应该是这样的:

en:
  formats:
   view_all_other: "View all other %{format_title}"

答案 1 :(得分:0)

facepalm 我遇到了另一个翻译的问题,我最初调用变量'format',我怀疑它可能是一个保留字或类似的东西所以我改变了所有的翻译使用format_title并忘了更新视图。