Load all subdirectories of config/locales

By default, rails will load all of the locale subfiles in the config/locales directory.

But any decent sized application will need to store locale files in a well organized subdirectory structure, not just all in config/locales. To have rails load all of the subdirectories in addition to config/locales, use this code:

  # in application.rb

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s