aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2008-11-18 00:41:52 +0100
committerXavier Noria <fxn@hashref.com>2008-11-18 00:41:52 +0100
commitc62f973c749beac8947ff5119af43fbde2547eb1 (patch)
tree4449ceca591cb3865946295224344c13e1bbbd41
parent90a1a9a2253381ba0799848beadf29232affb8d5 (diff)
parent047657cdfb7ad63ede151d84fbb922d63f641437 (diff)
downloadrails-c62f973c749beac8947ff5119af43fbde2547eb1.tar.gz
rails-c62f973c749beac8947ff5119af43fbde2547eb1.tar.bz2
rails-c62f973c749beac8947ff5119af43fbde2547eb1.zip
Merge branch 'master' of git@github.com:lifo/docrails
-rw-r--r--railties/doc/guides/source/actioncontroller_basics/cookies.txt2
-rw-r--r--railties/doc/guides/source/actioncontroller_basics/filters.txt4
-rw-r--r--railties/doc/guides/source/actioncontroller_basics/parameter_filtering.txt4
-rw-r--r--railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt6
-rw-r--r--railties/doc/guides/source/actioncontroller_basics/streaming.txt2
-rw-r--r--railties/doc/guides/source/actioncontroller_basics/verification.txt2
-rw-r--r--railties/doc/guides/source/i18n.txt541
-rw-r--r--railties/doc/guides/source/index.txt10
8 files changed, 561 insertions, 10 deletions
diff --git a/railties/doc/guides/source/actioncontroller_basics/cookies.txt b/railties/doc/guides/source/actioncontroller_basics/cookies.txt
index 88b99de3ee..9c30d29db4 100644
--- a/railties/doc/guides/source/actioncontroller_basics/cookies.txt
+++ b/railties/doc/guides/source/actioncontroller_basics/cookies.txt
@@ -31,4 +31,4 @@ class CommentsController < ApplicationController
end
-----------------------------------------
-Note that while for session values, you set the key to `nil`, to delete a cookie value, you should use `cookies.delete(:key)`.
+Note that while for session values you set the key to `nil`, to delete a cookie value you should use `cookies.delete(:key)`.
diff --git a/railties/doc/guides/source/actioncontroller_basics/filters.txt b/railties/doc/guides/source/actioncontroller_basics/filters.txt
index df67977efd..09a4bdf4f6 100644
--- a/railties/doc/guides/source/actioncontroller_basics/filters.txt
+++ b/railties/doc/guides/source/actioncontroller_basics/filters.txt
@@ -38,7 +38,7 @@ class ApplicationController < ActionController::Base
end
---------------------------------
-In this example, the filter is added to ApplicationController and thus all controllers in the application. This will make everything in the application require the user to be logged in in order to use it. For obvious reasons (the user wouldn't be able to log in in the first place!), not all controllers or actions should require this. You can prevent this filter from running before particular actions with `skip_before_filter` :
+In this example, the filter is added to ApplicationController and thus all controllers in the application. This will make everything in the application require the user to be logged in in order to use it. For obvious reasons (the user wouldn't be able to log in in the first place!), not all controllers or actions should require this. You can prevent this filter from running before particular actions with `skip_before_filter`:
[source, ruby]
---------------------------------
@@ -49,7 +49,7 @@ class LoginsController < Application
end
---------------------------------
-Now, the +LoginsController+'s "new" and "create" actions will work as before without requiring the user to be logged in. The `:only` option is used to only skip this filter for these actions, and there is also an `:except` option which works the other way. These options can be used when adding filters too, so you can add a filter which only runs for selected actions in the first place.
+Now, the LoginsController's `new` and `create` actions will work as before without requiring the user to be logged in. The `:only` option is used to only skip this filter for these actions, and there is also an `:except` option which works the other way. These options can be used when adding filters too, so you can add a filter which only runs for selected actions in the first place.
=== After Filters and Around Filters ===
diff --git a/railties/doc/guides/source/actioncontroller_basics/parameter_filtering.txt b/railties/doc/guides/source/actioncontroller_basics/parameter_filtering.txt
index e29f631038..0013492b73 100644
--- a/railties/doc/guides/source/actioncontroller_basics/parameter_filtering.txt
+++ b/railties/doc/guides/source/actioncontroller_basics/parameter_filtering.txt
@@ -1,6 +1,6 @@
== Parameter Filtering ==
-Rails keeps a log file for each environment (development, test and production) in the "log" folder. These are extremely useful when debugging what's actually going on in your application, but in a live application you may not want every bit of information to be stored in the log file. The `filter_parameter_logging` method can be used to filter out sensitive information from the log. It works by replacing certain values in the `params` hash with "[FILTERED]" as they are written to the log. As an example, let's see how to filter all parameters with keys that include "password":
+Rails keeps a log file for each environment (development, test and production) in the `log` folder. These are extremely useful when debugging what's actually going on in your application, but in a live application you may not want every bit of information to be stored in the log file. The `filter_parameter_logging` method can be used to filter out sensitive information from the log. It works by replacing certain values in the `params` hash with "[FILTERED]" as they are written to the log. As an example, let's see how to filter all parameters with keys that include "password":
[source, ruby]
-------------------------
@@ -11,4 +11,4 @@ class ApplicationController < ActionController::Base
end
-------------------------
-The method works recursively through all levels of the params hash and takes an optional second parameter which is used as the replacement string if present. It can also take a block which receives each key in return and replaces those for which the block returns true.
+The method works recursively through all levels of the params hash and takes an optional second parameter which is used as the replacement string if present. It can also take a block which receives each key in turn and replaces those for which the block returns true.
diff --git a/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt b/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt
index 07a8ec2574..846c24052d 100644
--- a/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt
+++ b/railties/doc/guides/source/actioncontroller_basics/request_response_objects.txt
@@ -7,13 +7,13 @@ In every controller there are two accessor methods pointing to the request and t
The request object contains a lot of useful information about the request coming in from the client. To get a full list of the available methods, refer to the link:http://api.rubyonrails.org/classes/ActionController/AbstractRequest.html[API documentation]. Among the properties that you can access on this object are:
* host - The hostname used for this request.
- * domain - The hostname without the first segment (usually "www").
+ * domain(n=2) - The hostname's first `n` segments, starting from the right (the TLD)
* format - The content type requested by the client.
* method - The HTTP method used for the request.
- * get?, post?, put?, delete?, head? - Returns true if the HTTP method is get/post/put/delete/head.
+ * get?, post?, put?, delete?, head? - Returns true if the HTTP method is GET/POST/PUT/DELETE/HEAD.
* headers - Returns a hash containing the headers associated with the request.
* port - The port number (integer) used for the request.
- * protocol - The protocol used for the request.
+ * protocol - Returns a string containing the prototol used plus "://", for example "http://"
* query_string - The query string part of the URL - everything after "?".
* remote_ip - The IP address of the client.
* url - The entire URL used for the request.
diff --git a/railties/doc/guides/source/actioncontroller_basics/streaming.txt b/railties/doc/guides/source/actioncontroller_basics/streaming.txt
index dc8ebe6d55..2a930835ee 100644
--- a/railties/doc/guides/source/actioncontroller_basics/streaming.txt
+++ b/railties/doc/guides/source/actioncontroller_basics/streaming.txt
@@ -52,7 +52,7 @@ This will read and stream the file 4Kb at the time, avoiding loading the entire
WARNING: Be careful when using (or just don't use) "outside" data (params, cookies, etc) to locate the file on disk, as this is a security risk that might allow someone to gain access to files they are not meant to see.
-TIP: It is not recommended that you stream static files through Rails if you can instead keep them in a public folder on your web server. It is much more efficient to let the user download the file directly using Apache or another web server, keeping the request from unnecessarily going through the whole Rails stack.
+TIP: It is not recommended that you stream static files through Rails if you can instead keep them in a public folder on your web server. It is much more efficient to let the user download the file directly using Apache or another web server, keeping the request from unnecessarily going through the whole Rails stack. Although if you do need the request to go through Rails for some reason, you can set the `:x_sendfile` option to true, and Rails will let the web server handle sending the file to the user, freeing up the Rails process to do other things. Note that your web server needs to support the `X-Sendfile` header for this to work, and you still have to be careful not to use user input in a way that lets someone retrieve arbitrary files.
=== RESTful Downloads ===
diff --git a/railties/doc/guides/source/actioncontroller_basics/verification.txt b/railties/doc/guides/source/actioncontroller_basics/verification.txt
index 5d8ee6117e..a4522a0102 100644
--- a/railties/doc/guides/source/actioncontroller_basics/verification.txt
+++ b/railties/doc/guides/source/actioncontroller_basics/verification.txt
@@ -25,7 +25,7 @@ class LoginsController < ApplicationController
end
---------------------------------------
-Now the `create` action won't run unless the "username" and "password" parameters are present, and if they're not, an error message will be added to the flash and the "new" action will be rendered. But there's something rather important missing from the verification above: It will be used for *every* action in LoginsController, which is not what we want. You can limit which actions it will be used for with the `:only` and `:except` options just like a filter:
+Now the `create` action won't run unless the "username" and "password" parameters are present, and if they're not, an error message will be added to the flash and the `new` action will be rendered. But there's something rather important missing from the verification above: It will be used for *every* action in LoginsController, which is not what we want. You can limit which actions it will be used for with the `:only` and `:except` options just like a filter:
[source, ruby]
---------------------------------------
diff --git a/railties/doc/guides/source/i18n.txt b/railties/doc/guides/source/i18n.txt
new file mode 100644
index 0000000000..c9867ba0ac
--- /dev/null
+++ b/railties/doc/guides/source/i18n.txt
@@ -0,0 +1,541 @@
+The Rails Internationalization API
+==================================
+
+The Ruby I18n gem which is shipped with Ruby on Rails (starting from Rails 2.2) provides an easy-to-use and extensible framework for translating your application to a single custom language other than English or providing multi-language support in your application.
+
+== How I18n in Ruby on Rails works
+
+Internationalization is a complex problem. Natural languages differ in so many ways that it is hard to provide tools for solving all problems at once. For that reason the Rails I18n API focusses on:
+
+* providing support for English and similar languages out of the box
+* making it easy to customize and extend everything for other languages
+
+=== The overall architecture of the library
+
+To solve this the Ruby I18n gem is split into two parts:
+
+* The public API which is just a Ruby module with a bunch of public methods and definitions how the library works.
+* A shipped backend (which is intentionally named the Simple backend) that implements these methods.
+
+As a user you should always only access the public methods on the I18n module but it is useful to know about the capabilities of the backend you use and maybe exchange the shipped Simple backend with a more powerful one.
+
+=== The public I18n API
+
+We will go into more detail about the public methods later but here's a quick overview. The most important methods are:
+
+[source, ruby]
+-------------------------------------------------------
+translate # lookup translations
+localize # localize Date and Time objects to local formats
+-------------------------------------------------------
+
+There are also attribute readers and writers for the following attributes:
+
+[source, ruby]
+-------------------------------------------------------
+load_path # announce your custom translation files
+locale # get and set the current locale
+default_locale # get and set the default locale
+exception_handler # use a different exception_handler
+backend # use a different backend
+-------------------------------------------------------
+
+== Walkthrough: setup a simple I18n'ed Rails application
+
+There are just a few, simple steps to get up and running with a I18n support for your application.
+
+=== Configure the I18n module
+
+First of all you want to tell the I18n library where it can find your custom translation files. You might also want to set your default locale to something else than English.
+
+You can pick whatever directory and translation file naming scheme makes sense for you. The simplest thing possible is probably to put the following into an initializer:
+
+[source, ruby]
+-------------------------------------------------------
+# in config/initializer/locale.rb
+
+# tell the I18n library where to find your translations
+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.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.
+
+=== 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).
+
+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:
+
+[source, ruby]
+-------------------------------------------------------
+before_filter :set_locale
+def set_locale
+ # if this is nil then I18n.default_locale will be used
+ I18n.locale = params[:locale]
+end
+-------------------------------------------------------
+
+This will already work for URLs where you pass the locale as a query parameter as in example.com?locale=pt-BR (which is what Google also does). (TODO hints about other approaches in the resources section).
+
+Now you've initialized I18n support for your application and told it which locale should be used. With that in place you're now ready for the really interesting stuff.
+
+=== Internationalize your application
+
+The process of "internationalization" usually means to abstract all strings and other locale specific bits out of your application (TODO reference to wikipedia). The process of "localization" means to then provide translations and localized formats for these bits.
+
+So, let's internationalize something. You most probably have something like this in one of your applications:
+
+[source, ruby]
+-------------------------------------------------------
+# config/routes.rb
+ActionController::Routing::Routes.draw do |map|
+ map.root :controller => 'home', :action => 'index'
+end
+
+# app/controllers/home_controller.rb
+class HomeController < ApplicationController
+ def index
+ flash[:notice] = "Hello flash!"
+ end
+end
+
+# app/views/home/index.html.erb
+<h1>Hello world!</h1>
+<p><%= flash[:notice] %></p>
+-------------------------------------------------------
+
+TODO screenshot
+
+Obviously there are two strings that are localized to English. In order to internationalize this code replace these strings with calls to Rails' #t helper with a key that makes sense for the translation:
+
+[source, ruby]
+-------------------------------------------------------
+# app/controllers/home_controller.rb
+class HomeController < ApplicationController
+ def index
+ flash[:notice] = t(:hello_flash)
+ end
+end
+
+# app/views/home/index.html.erb
+<h1><%=t :hello_world %></h1>
+<p><%= flash[:notice] %></p>
+-------------------------------------------------------
+
+TODO insert note about #t helper compared to I18n.t
+
+TODO insert note/reference about structuring translation keys
+
+When you now render this view it will show an error message that tells you that the translations for the keys :hello_world and :hello_flash are missing.
+
+TODO screenshot
+
+So let's add the missing translations (i.e. do the "localization" part):
+
+[source, ruby]
+-------------------------------------------------------
+# lib/locale/en-US.yml
+en-US:
+ hello_world: Hello World
+ hello_flash: Hello Flash
+
+# lib/locale/pirate.yml
+pirate:
+ hello_world: Ahoy World
+ hello_flash: Ahoy Flash
+-------------------------------------------------------
+
+There you go. Your application now shows:
+
+TODO screenshot
+
+[source, ruby]
+-------------------------------------------------------
+I18n.t 'store.title'
+I18n.l Time.now
+-------------------------------------------------------
+
+
+== Overview of the I18n API features
+
+The following purposes are covered:
+
+* lookup translations
+* interpolate data into translations
+* pluralize translations
+* localize dates, numbers, currency etc.
+
+=== Looking up translations
+
+==== Basic lookup, scopes and nested keys
+
+Translations are looked up by keys which can be both Symbols or Strings, so these calls are equivalent:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.t :message
+I18n.t 'message'
+-------------------------------------------------------
+
+translate also takes a :scope option which can contain one or many additional keys that will be used to specify a “namespace” or scope for a translation key:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.t :invalid, :scope => [:active_record, :error_messages]
+-------------------------------------------------------
+
+This looks up the :invalid message in the ActiveRecord error messages.
+
+Additionally, both the key and scopes can be specified as dot separated keys as in:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.translate :"active_record.error_messages.invalid"
+-------------------------------------------------------
+
+Thus the following calls are equivalent:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.t 'active_record.error_messages.invalid'
+I18n.t 'error_messages.invalid', :scope => :active_record
+I18n.t :invalid, :scope => 'active_record.error_messages'
+I18n.t :invalid, :scope => [:active_record, :error_messages]
+-------------------------------------------------------
+
+==== Defaults
+
+When a default option is given its value will be returned if the translation is missing:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.t :missing, :default => 'Not here'
+# => 'Not here'
+-------------------------------------------------------
+
+If the default value is a Symbol it will be used as a key and translated. One can provide multiple values as default. The first one that results in a value will be returned.
+
+E.g. the following first tries to translate the key :missing and then the key :also_missing. As both do not yield a result the string ‘Not here’ will be returned:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.t :missing, :default => [:also_missing, 'Not here']
+# => 'Not here'
+-------------------------------------------------------
+
+==== Bulk and namespace lookup
+
+To lookup multiple translations at once an array of keys can be passed:
+
+[source, ruby]
+-------------------------------------------------------
+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:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.t 'active_record.error_messages'
+# => { :inclusion => "is not included in the list", :exclusion => ... }
+-------------------------------------------------------
+
+=== Interpolation
+
+TODO explain what this is good for
+
+All options besides :default and :scope that are passed to #translate will be interpolated to the translation:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.backend.store_translations 'en-US', :thanks => 'Thanks {{name}}!'
+I18n.translate :thanks, :name => 'Jeremy'
+# => 'Thanks Jeremy!'
+-------------------------------------------------------
+
+If a translation uses :default or :scope as a interpolation variable an I18n::ReservedInterpolationKey exception is raised. If a translation expects an interpolation variable but it has not been passed to #translate an I18n::MissingInterpolationArgument exception is raised.
+
+=== Pluralization
+
+TODO explain what this is good for
+
+The :count interpolation variable has a special role in that it both is interpolated to the translation and used to pick a pluralization from the translations according to the pluralization rules defined by CLDR:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.backend.store_translations 'en-US', :inbox => { # TODO change this
+ :one => '1 message',
+ :other => '{{count}} messages'
+}
+I18n.translate :inbox, :count => 2
+# => '2 messages'
+-------------------------------------------------------
+
+The algorithm for pluralizations in en-US is as simple as:
+
+[source, ruby]
+-------------------------------------------------------
+entry[count == 1 ? 0 : 1]
+-------------------------------------------------------
+
+I.e. the translation denoted as :one is regarded as singular, the other is used as plural (including the count being zero).
+
+If the lookup for the key does not return an Hash suitable for pluralization an I18n::InvalidPluralizationData exception is raised.
+
+=== Setting and passing a locale
+
+The locale can be either set pseudo-globally to I18n.locale (which uses Thread.current like, e.g., Time.zone) or can be passed as an option to #translate and #localize.
+
+If no locale is passed I18n.locale is used:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.locale = :'de-DE'
+I18n.t :foo
+I18n.l Time.now
+-------------------------------------------------------
+
+Explicitely passing a locale:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.t :foo, :locale => :'de-DE'
+I18n.l Time.now, :locale => :'de-DE'
+-------------------------------------------------------
+
+I18n.locale defaults to I18n.default_locale which defaults to :'en-US'. The default locale can be set like this:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.default_locale = :'de-DE'
+-------------------------------------------------------
+
+== How to store your custom translations
+
+The shipped Simple backend allows you to store translations in both plain Ruby and YAML format. (2)
+
+For example a Ruby Hash providing translations can look like this:
+
+[source, ruby]
+-------------------------------------------------------
+{
+ :'pt-BR' => {
+ :foo => {
+ :bar => "baz"
+ }
+ }
+}
+-------------------------------------------------------
+
+The equivalent YAML file would look like this:
+
+[source, ruby]
+-------------------------------------------------------
+"pt-BR":
+ foo:
+ bar: baz
+-------------------------------------------------------
+
+As you see in both cases the toplevel key is the locale. :foo is a namespace key and :bar is the key for the translation "baz".
+
+Here is a "real" example from the ActiveSupport en-US translations YAML file:
+
+[source, ruby]
+-------------------------------------------------------
+"en-US":
+ date:
+ formats:
+ default: "%Y-%m-%d"
+ short: "%b %d"
+ long: "%B %d, %Y"
+-------------------------------------------------------
+
+So, all of the following equivalent lookups will return the :short date format "%B %d":
+
+[source, ruby]
+-------------------------------------------------------
+I18n.t 'date.formats.short'
+I18n.t 'formats.short', :scope => :date
+I18n.t :short, :scope => 'date.formats'
+I18n.t :short, :scope => [:date, :formats]
+-------------------------------------------------------
+
+=== 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:
+ activerecord:
+ models:
+ user: Dude
+ attributes:
+ user:
+ login: "Handle"
+ # will translate User attribute "login" as "Handle"
+
+Then User.human_name will return "Dude" and User.human_attribute_name(:login) will return "Handle".
+
+==== 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.
+
+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:
+
+[source, ruby]
+-------------------------------------------------------
+class User < ActiveRecord::Base
+ validates_presence_of :name
+end
+-------------------------------------------------------
+
+The key for the error message in this case is :blank. So ActiveRecord will first try to look up an error message with:
+
+[source, ruby]
+-------------------------------------------------------
+activerecord.errors.messages.models.user.attributes.name.blank
+-------------------------------------------------------
+
+If it's not there it will try:
+
+[source, ruby]
+-------------------------------------------------------
+activerecord.errors.messages.models.user.blank
+-------------------------------------------------------
+
+If this is also not there it will use the default message from:
+
+[source, ruby]
+-------------------------------------------------------
+activerecord.errors.messages.blank
+-------------------------------------------------------
+
+When your models are additionally using inheritance then the messages are looked up for the inherited model class names are looked up.
+
+For example, you might have an Admin model inheriting from User:
+
+[source, ruby]
+-------------------------------------------------------
+class Admin < User
+ validates_presence_of :name
+end
+-------------------------------------------------------
+
+Then ActiveRecord will look for messages in this order:
+
+[source, ruby]
+-------------------------------------------------------
+activerecord.errors.models.admin.attributes.title.blank
+activerecord.errors.models.admin.blank
+activerecord.errors.models.user.attributes.title.blank
+activerecord.errors.models.user.blank
+activerecord.errors.messages.blank
+-------------------------------------------------------
+
+This way you can provide special translations for various error messages at different points in your models inheritance chain and in the attributes, models or default scopes.
+
+==== Error message interpolation
+
+The translated model name and translated attribute name are always available for interpolation.
+
+So, for example, instead of the default error message "can not be blank" you could use the attribute name like this: "Please fill in your {{attribute}}".
+
+Count and/or value are available where applicable. Count can be used for pluralization if present:
+
+[grid="all"]
+`---------------------------`----------------`---------------`----------------
+validation with option message interpolation
+validates_confirmation_of - :confirmation -
+validates_acceptance_of - :accepted -
+validates_presence_of - :blank -
+validates_length_of :within, :in :too_short count
+validates_length_of :within, :in :too_long count
+validates_length_of :is :wrong_length count
+validates_length_of :minimum :too_short count
+validates_length_of :maximum :too_long count
+validates_uniqueness_of - :taken value
+validates_format_of - :invalid value
+validates_inclusion_of - :inclusion value
+validates_exclusion_of - :exclusion value
+validates_associated - :invalid value
+validates_numericality_of - :not_a_number value
+validates_numericality_of :odd :odd value
+validates_numericality_of :even :even value
+------------------------------------------------------------------------------
+
+
+==== Translations for the ActiveRecord error_messages_for helper
+
+If you are using the ActiveRecord error_messages_for helper you will want to add translations for it.
+
+Rails ships with the following translations:
+
+[source, ruby]
+-------------------------------------------------------
+"en-US":
+ activerecord:
+ errors:
+ template:
+ header:
+ one: "1 error prohibited this {{model}} from being saved"
+ other: "{{count}} errors prohibited this {{model}} from being saved"
+ body: "There were problems with the following fields:"
+-------------------------------------------------------
+
+
+=== Other translations and localizations
+
+Rails uses fixed strings and other localizations, such as format strings and other format information in a couple of helpers.
+
+TODO list helpers and available keys
+
+== Customize your I18n setup
+
+=== Using different backends
+
+For several reasons the shipped Simple backend only does the "simplest thing that ever could work" _for Ruby on Rails_ (1) ... which means that it is only guaranteed to work for English and, as a side effect, languages that are very similar to English. Also, the simple backend is only capable of reading translations but can not dynamically store them to any format.
+
+That does not mean you're stuck with these limitations though. The Ruby I18n gem makes it very easy to exchange the Simple backend implementation with something else that fits better for your needs. E.g. you could exchange it with Globalize's Static backend:
+
+[source, ruby]
+-------------------------------------------------------
+I18n.backend = Globalize::Backend::Static.new
+-------------------------------------------------------
+
+TODO expand this ...? list some backends and their features?
+
+=== Using different exception handlers
+
+TODO
+
+* Explain what exceptions are raised and why we are using exceptions for communication from backend to frontend.
+* Explain the default behaviour.
+* Explain the :raise option
+
+* Example 1: the Rails #t helper uses a custom exception handler that catches I18n::MissingTranslationData and wraps the message into a span with the CSS class "translation_missing"
+* Example 2: for tests you might want a handler that just raises all exceptions all the time
+* Example 3: a handler
+
+
+== Resources
+
+
+== Footnotes
+
+(1) One of these reasons is that we don't want to any unnecessary load for applications that do not need any I18n capabilities, so we need to keep the I18n library as simple as possible for English. Another reason is that it is virtually impossible to implement a one-fits-all solution for all problems related to I18n for all existing languages. So a solution that allows us to exchange the entire implementation easily is appropriate anyway. This also makes it much easier to experiment with custom features and extensions.
+
+(2) Other backends might allow or require to use other formats, e.g. a GetText backend might allow to read GetText files.
+
+== Credits
+
+== NOTES
+
+How to contribute?
+
diff --git a/railties/doc/guides/source/index.txt b/railties/doc/guides/source/index.txt
index 8828e1d313..a5648fb757 100644
--- a/railties/doc/guides/source/index.txt
+++ b/railties/doc/guides/source/index.txt
@@ -113,6 +113,16 @@ This guide covers ways to analyze and optimize your running Rails code.
This guide covers how to build a plugin to extend the functionality of Rails.
***********************************************************
+.link:i18n.html[The Rails Internationalization API]
+***********************************************************
+CAUTION: still a basic draft
+
+This guide introduces you to the basic concepts and features of the Rails I18n API and shows you how to localize your application.
+***********************************************************
+
+
+
+
Authors who have contributed to complete guides are listed link:authors.html[here].
This work is licensed under a link:http://creativecommons.org/licenses/by-nc-sa/3.0/[Creative Commons Attribution-Noncommercial-Share Alike 3.0 License]