I am trying to organize my localization files with a nested file structure so that it is easier to look up.
I have followed
Organization of Locale Files in rails app
How do you structure i18n yaml files in Rails?
but I am getting a translation missing: en.view.fruits.apple
. I think that Rails is trying to only look up the translation in locales/en.yml
file but not the sub-directories although, I have included them.
config/application.rb:
config.i18n.load_path += Dir["#{Rails.root.to_s}/config/locales/**/*.{rb,yml}"]
My locales directory:
|locales
|-en.yml
|-views
|--en.yml
locales/views/en.yml:
en:
fruits:
apple: "apple"
views/fruit.html.haml:
= I18n.t('views.fruits.apple')