From 8ad2f93a309e57e67286e0c4426b1ad003b9b33b Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 21 Jan 2009 21:35:53 +0000 Subject: ActiveRecord => Active Record --- railties/doc/guides/html/i18n.html | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'railties/doc/guides/html') diff --git a/railties/doc/guides/html/i18n.html b/railties/doc/guides/html/i18n.html index 47a9abb93c..386b801d64 100644 --- a/railties/doc/guides/html/i18n.html +++ b/railties/doc/guides/html/i18n.html @@ -84,7 +84,7 @@ How to store your custom translations -

As part of this solution, every static string in the Rails framework — eg. ActiveRecord validation messages, time and date formats — has been internationalized, so localization of a Rails application means "over-riding" these defaults.

+

As part of this solution, every static string in the Rails framework — eg. Active Record validation messages, time and date formats — has been internationalized, so localization of a Rails application means "over-riding" these defaults.

1.1. The overall architecture of the library

Thus, the Ruby I18n gem is split into two parts:

-

This means, that in the :en locale, the key hello will map to Hello world string. Every string inside Rails is internationalized in this way, see for instance ActiveRecord validation messages in the activerecord/lib/active_record/locale/en.yml file or time and date formats in the activesupport/lib/active_support/locale/en.yml file. You can use YAML or standard Ruby Hashes to store translations in the default (Simple) backend.

+

This means, that in the :en locale, the key hello will map to Hello world string. Every string inside Rails is internationalized in this way, see for instance Active Record validation messages in the activerecord/lib/active_record/locale/en.yml file or time and date formats in the activesupport/lib/active_support/locale/en.yml file. You can use YAML or standard Ruby Hashes to store translations in the default (Simple) backend.

The I18n library will use English as a default locale, ie. if you don’t set a different locale, :en will be used for looking up translations.

The translations load path (I18n.load_path) is just a Ruby Array of paths to your translation files that will be loaded automatically and available in your application. You can pick whatever directory and translation file naming scheme makes sense for you.

@@ -554,7 +554,7 @@ by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite -->
I18n.t :invalid, :scope => [:active_record, :error_messages]
-

This looks up the :invalid message in the ActiveRecord error messages.

+

This looks up the :invalid message in the Active Record error messages.

Additionally, both the key and scopes can be specified as dot separated keys as in:

I18n.t [:odd, :even], :scope => 'active_record.error_messages'
 # => ["must be odd", "must be even"]
-

Also, a key can translate to a (potentially nested) hash as grouped translations. E.g. one can receive all ActiveRecord error messages as a Hash with:

+

Also, a key can translate to a (potentially nested) hash as grouped translations. E.g. one can receive all Active Record error messages as a Hash with:

# will translate User attribute "login" as "Handle"

Then User.human_name will return "Dude" and User.human_attribute_name(:login) will return "Handle".

5.1.1. Error message scopes

-

ActiveRecord validation error messages can also be translated easily. ActiveRecord gives you a couple of namespaces where you can place your message translations in order to provide different messages and translation for certain models, attributes and/or validations. It also transparently takes single table inheritance into account.

+

Active Record validation error messages can also be translated easily. Active Record gives you a couple of namespaces where you can place your message translations in order to provide different messages and translation for certain models, attributes and/or validations. It also transparently takes single table inheritance into account.

This gives you quite powerful means to flexibly adjust your messages to your application’s needs.

Consider a User model with a validates_presence_of validation for the name attribute like this:

@@ -747,7 +747,7 @@ http://www.gnu.org/software/src-highlite -->
class User < ActiveRecord::Base
   validates_presence_of :name
 end
-

The key for the error message in this case is :blank. ActiveRecord will lookup this key in the namespaces:

+

The key for the error message in this case is :blank. Active Record will lookup this key in the namespaces:

class Admin < User
   validates_presence_of :name
 end
-

Then ActiveRecord will look for messages in this order:

+

Then Active Record will look for messages in this order: