Skip to content

Commit

Permalink
Finished the tutorial part of i18n guide (organization of locale files)
Browse files Browse the repository at this point in the history
  • Loading branch information
karmi committed Jan 26, 2009
1 parent b24f136 commit 095c89b
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion railties/doc/guides/source/i18n.txt
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,46 @@ image:images/i18n/demo_localized_pirate.png[rails i18n demo localized time to pi

TIP: Right now you might need to add some more date/time formats in order to make the I18n backend work as expected. Of course, there's a great chance that somebody already did all the work by *translating Rails's defaults for your locale*. See the http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale[rails-i18n repository at Github] for an archive of various locale files. When you put such file(s) in +config/locale/+ directory, they will automatically ready for use.

=== 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.

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

-------------------------------------------------------
|-defaults
|---es.rb
|---en.rb
|-models
|---book
|-----es.rb
|-----en.rb
|-views
|---defaults
|-----es.rb
|-----en.rb
|---books
|-----es.rb
|-----en.rb
|---users
|-----es.rb
|-----en.rb
|---navigation
|-----es.rb
|-----en.rb
-------------------------------------------------------

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.

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

== Overview of the I18n API features

The following purposes are covered:
By knowing all neccessary aspects of internationalizing a basic Ruby on Rails application, now you should have good understanding of using the i18n library. In the following chapters, we'll cover it's features in more depth.

Covered are features like these:

* lookup translations
* interpolate data into translations
Expand Down

0 comments on commit 095c89b

Please sign in to comment.