From a92a43c64822cc1922124f0de85e1e67163f8056 Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Sun, 30 Nov 2008 07:08:33 -0600 Subject: Regenerate Guides HTML --- railties/doc/guides/html/i18n.html | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'railties/doc/guides/html/i18n.html') diff --git a/railties/doc/guides/html/i18n.html b/railties/doc/guides/html/i18n.html index 3504a9e366..3ceba0f687 100644 --- a/railties/doc/guides/html/i18n.html +++ b/railties/doc/guides/html/i18n.html @@ -346,11 +346,11 @@ http://www.gnu.org/software/src-highlite --> I18n.load_path += Dir[ File.join(RAILS_ROOT, 'lib', 'locale', '*.{rb,yml}') ] # you can omit this if you're happy with English as a default locale -I18n.default_locale = :"pt-BR" +I18n.default_locale = :"pt"

I18n.load_path is just a Ruby Array of paths to your translation files. The backend will lazy-load these translations when a translation is looked up for the first time. This makes it possible to just swap the backend with something else even after translations have already been announced.

2.2. Set the locale in each request

-

By default the I18n library will use the I18n.default_locale for looking up translations (if you do not specify a locale for a lookup) and this will, by default, en-US (American English).

+

By default the I18n library will use the I18n.default_locale for looking up translations (if you do not specify a locale for a lookup) and this will, by default, en (English).

If you want to translate your Rails application to a single language other than English you can set I18n.default_locale to your locale. If you want to change the locale on a per-request basis though you can set it in a before_filter on the ApplicationController like this:

by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
# lib/locale/en-US.yml
+
# lib/locale/en.yml
 en-US:
   hello_world: Hello World
   hello_flash: Hello Flash
@@ -549,7 +549,7 @@ http://www.gnu.org/software/src-highlite -->
 by Lorenzo Bettini
 http://www.lorenzobettini.it
 http://www.gnu.org/software/src-highlite -->
-
I18n.backend.store_translations 'en-US', :thanks => 'Thanks {{name}}!'
+
I18n.backend.store_translations 'en', :thanks => 'Thanks {{name}}!'
 I18n.translate :thanks, :name => 'Jeremy'
 # => 'Thanks Jeremy!'
 
@@ -587,7 +587,7 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
I18n.locale = :'de-DE'
+
I18n.locale = :'de'
 I18n.t :foo
 I18n.l Time.now
 
@@ -597,16 +597,16 @@ I18n.l Time. -
I18n.t :foo, :locale => :'de-DE'
-I18n.l Time.now, :locale => :'de-DE'
+
I18n.t :foo, :locale => :'de'
+I18n.l Time.now, :locale => :'de'
 
-

I18n.locale defaults to I18n.default_locale which defaults to :en-US. The default locale can be set like this:

+

I18n.locale defaults to I18n.default_locale which defaults to :en. The default locale can be set like this:

-
I18n.default_locale = :'de-DE'
+
I18n.default_locale = :'de'
 

4. How to store your custom translations

@@ -643,7 +643,7 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
"en-US":
+
"en":
   date:
     formats:
       default: "%Y-%m-%d"
@@ -664,7 +664,7 @@ I18n.t :
 

4.1. Translations for ActiveRecord models

You can use the methods Model.human_name and Model.human_attribute_name(attribute) to transparently lookup translations for your model and attribute names.

For example when you add the following translations:

-

en-US: +

en: activerecord: models: user: Dude @@ -996,7 +996,7 @@ cellspacing="0" cellpadding="4"> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -

"en-US":
+
"en":
   activerecord:
     errors:
       template:
@@ -1059,6 +1059,13 @@ Example 3: a handler
 

6. Resources

+

7. Footnotes

-- cgit v1.2.3