Configure Rails 3’s I18N load path for subdirectories

If you’re like me you want to use nested directories to organize all of your files, especially when it comes to internationalization (I18N). I just found out about the nifty views trick that uses your current controller and action as the first part of your translation key. For example, let’s say you are looking at a list of all uploads you might be viewing the action:

Inside the template you probably have:

<h1><%= t('.title') %></h1>

Because of the leading dot Rails will be looking for the key defined as (assuming :en locale):

      title: Your title

Since you’re going to have a lot of locale files, you might think of placing the English locale file in:


Which is all well and good until you realize the I18N load path doesn’t include subdirectories. A quick fix to application.rb is all it takes though. Add:

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

The ** is the magic there.