0

If I just do

= t('.foo')

in a view file and I have no this translate in locale, it just capitalize the key and the result will be Foo

But why it's not happens in other places such as input attributes? This example show translate missing error:

= f.submit t('.foo')
4

1 回答 1

1

t 是视图助手(请参阅此处的文档:http: //api.rubyonrails.org/classes/ActionView/Helpers/TranslationHelper.html#method-i-translate

如果键存在,它只会输出翻译后的字符串,但缺少翻译键的返回值为<span class=“translation_missing” title=“translation missing: .foo”&gt; Foo </span>.

在这种= t('.foo')情况下,您看不到任何特别之处,因为跨度与您的文本内联,并且您没有任何专用格式(但请看一下,跨度会在缺少翻译的情况下出现)。但在这种= f.submit t('.foo')情况下,这变成了按钮上的文本,所以你注意到了。

于 2013-05-30T17:55:26.687 回答