Ruby on rails 铁路本地化“;“懒惰”;查找

Ruby on rails 铁路本地化“;“懒惰”;查找,ruby-on-rails,view,localization,rails-i18n,Ruby On Rails,View,Localization,Rails I18n,我有这样的看法: views layouts visitors _footer.html.haml _header.html.haml visitors.html.haml 在我的config/application.rb中,我添加了 config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s] 我的区域设置文件结构如下所示:

我有这样的看法:

views
  layouts
    visitors
      _footer.html.haml
      _header.html.haml
    visitors.html.haml
在我的
config/application.rb
中,我添加了

config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
我的区域设置文件结构如下所示:

config
  locales
    views
      layouts
        visitors.en.yml
我的访客。恩。yml有这样的结构

en:
  layouts:
    visitors:
      title: Site title
在我的
视图/layouts/visitors.html.haml
中,我调用了
I18n.t('.title')
,但收到错误
翻译缺少en.title

如果我喜欢这个
I18n.t('layouts.visitors.title')
,它可以正确地翻译所有内容


我做错了什么?

已经找到了答案。事实证明,只有当我像这样调用helper
t('.title')
时,Rails功能才起作用。只有这样,才能选择适当的翻译。如果我使用
I18n.t
只有full
I18n.t('layouts.visitors.title')
可以正常工作