Skip to content

Commit

Permalink
Added note how to configure Rails loading mechanism to look for neste…
Browse files Browse the repository at this point in the history
…d locale files (+config/locales/models/book/es.yml+, etc) to the I18N guide
  • Loading branch information
karmi committed Mar 1, 2009
1 parent e1c0763 commit 48d4c0f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions railties/guides/source/i18n.textile
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ TIP: Right now you might need to add some more date/time formats in order to mak

h4. Organization of locale files

When you are using the default SimpleStore, shipped with the i18n library, you store dictionaries in plain-text files on the disc. Putting translations for all parts of your application in one file per locale could be hard to manage. You can store these files in a hierarchy which makes sense to you.
When you are using the default SimpleStore, shipped with the i18n library, dictionaries are stored in plain-text files on the disc. Putting translations for all parts of your application in one file per locale could be hard to manage. You can store these files in a hierarchy which makes sense to you.

For example, your +config/locale+ directory could look like this:

Expand All @@ -443,9 +443,14 @@ For example, your +config/locale+ directory could look like this:
|-----en.rb
</pre>

This way, you can separate model and model attribute names from text inside views, and all of this from the "defaults" (eg. date and time formats).
This way, you can separate model and model attribute names from text inside views, and all of this from the "defaults" (eg. date and time formats). Other stores for the i18n library could provide different means of such separation.

Other stores for the i18n library could provide different means of such separation.
NOTE: The default locale loading mechanism in Rails does not load locale files in nested dictionaries, like we have here. So, for this to work, we must explicitely tell Rails to look further:

<ruby>
# config/environment.rb
config.i18n.load_path += Dir[File.join(RAILS_ROOT, 'config', 'locales', '**', '*.{rb,yml}')]
</ruby>

Do check the "Rails i18n Wiki":http://rails-i18n.org/wiki for list of tools available for managing translations.

Expand Down

0 comments on commit 48d4c0f

Please sign in to comment.