From 92dd9b3e9f7bffe16ec53aeefd048d7da4eb1543 Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Sun, 1 Mar 2009 12:06:50 +0100 Subject: Added information about "Localized views" into I18N guide See: * http://github.com/rails/rails/commit/a98cd7ca9b2f24a4500963e58ba5c37d6bdf9259 * http://afreshcup.com/2009/02/01/rails-23-localized-views/ --- railties/guides/source/i18n.textile | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties') diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index bc8be1f068..f5a50ee78b 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -414,6 +414,12 @@ So that would give you: 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 "rails-i18n repository at Github":http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale for an archive of various locale files. When you put such file(s) in +config/locale/+ directory, they will automatically ready for use. +h4. Localized views + +Rails 2.3 brings one convenient feature: localized views (templates). Let's say you have a _BooksController_ in your application. Your _index_ action renders content in +app/views/books/index.html.erb+ template. When you put a _localized variant_ of this template: *+index.es.html.erb+* in the same directory, Rails will render content in this template, when the locale is set to +:es+. When the locale is set to the default locale, generic +index.html.erb+ view will be used. (Future Rails versions may well bring this _automagic_ localization to assets in +public+, etc.) + +You can make use this feature eg. when working with great amount of static content, which would be clumsy to put inside YAML or Ruby dictionaries. Bear in mind, though, that any change you would like to do later to the template must be propagated to all of them. + h4. Organization of locale files 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. -- cgit v1.2.3