Rails中I18n.t和t之间的差异

时间:2015-01-29 07:30:53

标签: ruby-on-rails ruby internationalization yaml

我有一个奇怪的问题。我的en.yml文件看起来像这样:

en:
  no_notifiaction: No Notification 
  active_notification: Active notification


t('.active_notification') == "Active notification" #false
I18n.t('.active_notification') == "Active notification" #true?

为什么?

1 个答案:

答案 0 :(得分:4)

查看documentation以及#34; Lazy Lookups"。 t('.active_notification')仅在相应的视图中可用。如果你打电话,请不要在javascript文件或任何其他视图中说...

相关问题