2

I've a project with carious locale files, organized in subdirectories depending of the model they correspond.

To make Rails load all of them, I've set this option in config/application.yml:

config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]

Now, executing rails console and writing something that requires the last locale file added (config/locale/email/en.yml), I get this:

Loading development environment (Rails 4.1.6)
2.1.3 :001 > I18n.t("email.footer_text")  
  => "translation missing: en.email.footer_text" 
2.1.3 :002 > translations = I18n.backend.send(:translations);
2.1.3 :003 > translations[:en][:email]  
  => nil

But, if I do it from a controller (with some help of putscommand), it prints the locale string good.

PD: In the console, it loads all the rest of locales, except the last added. I've tried to delete an old one, and the console (after a restart) gives me an error because the locale I've deleted doesn't exist.

Is there any kind of cache that I should clean?

Why the console remembers that a deleted file used to exist if I've restarted the console after deleting the file?

odarriba
  • 342
  • 2
  • 11

1 Answers1

1

You should load your locales in rails console manually first:

2.1.3 :001 > I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
Sibevin Wang
  • 4,480
  • 3
  • 27
  • 27