I have such views structure:
views
layouts
visitors
_footer.html.haml
_header.html.haml
visitors.html.haml
In my config/application.rb
I've added
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
My locales file structure looks like this:
config
locales
views
layouts
visitors.en.yml
My visitors.en.yml has such structure
en:
layouts:
visitors:
title: Site title
In my views/layouts/visitors.html.haml
I call I18n.t('.title')
, but receive error translation missing en.title
.
If I do like this I18n.t('layouts.visitors.title')
- it translates everything properly.
What I'm doing wrong?
Already found the answer. It turned out that this Rails feature works only when I call helper like this
t('.title')
. Only then the appropriate translation is picked up. If I useI18n.t
only fullI18n.t('layouts.visitors.title')
works properly.