在视图中显示缺少的I18n翻译

时间:2012-05-28 23:31:27

标签: ruby-on-rails ruby ruby-on-rails-3 actionview actionviewhelper

如上所述in ActionView's documentation,Rails中的t视图助手会自动破坏缺少的翻译。例如:

irb> helper.t('words.foo_bar')
=> "<span class="translation_missing" title="translation missing: en.words.foo_bar">Foo Bar</span>"

有没有办法全局禁用它?我更愿意看到“翻译缺失:en.words.asdf ”。

我发现的唯一解决方法是在视图中使用I18n.t "..."而不是t "..."

谢谢!

2 个答案:

答案 0 :(得分:2)

尝试将此代码放入development.rb

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = false

答案 1 :(得分:0)

我的config/initializers目录中有这个文件,它显示了所有失败的翻译查找以及它们来自日志输出的位置:https://gist.github.com/1594660

也许这正是您所寻找的。

相关问题