From 84e46437fa50782dd38b96b8df00ca8b017c892e Mon Sep 17 00:00:00 2001
From: Anil Wadghule <anildigital@gmail.com>
Date: Mon, 12 Apr 2010 22:20:55 +0530
Subject: Replace 'RAILS_ROOT' to 'Rails.root' and 'RAILS_ENV' to 'Rails.env'
 in significant places.

---
 railties/guides/source/i18n.textile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'railties/guides/source/i18n.textile')

diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile
index ec69f770ee..9e882bc0a1 100644
--- a/railties/guides/source/i18n.textile
+++ b/railties/guides/source/i18n.textile
@@ -103,7 +103,7 @@ The default +environment.rb+ files has instructions on how to add locales from a
 # The internationalization framework can be changed
 # to have another default locale (standard is :en) or more load paths.
 # All files from config/locales/*.rb,yml are added automatically.
-# config.i18n.load_path << Dir[File.join(RAILS_ROOT, 'my', 'locales', '*.{rb,yml}')]
+# config.i18n.load_path << Dir[File.join(Rails.root, 'my', 'locales', '*.{rb,yml}')]
 # config.i18n.default_locale = :de
 </ruby>
 
@@ -117,7 +117,7 @@ To tell the I18n library where it can find your custom translation files you can
 # in config/initializers/locale.rb
 
 # tell the I18n library where to find your translations
-I18n.load_path << Dir[ File.join(RAILS_ROOT, 'lib', 'locale', 
+I18n.load_path << Dir[ File.join(Rails.root, 'lib', 'locale', 
   '*.{rb,yml}') ]
 
 # set default locale to something other than :en
@@ -423,7 +423,7 @@ NOTE: The default locale loading mechanism in Rails does not load locale files i
 
 <ruby>
   # config/environment.rb
-  config.i18n.load_path += Dir[File.join(RAILS_ROOT, 'config', 'locales', '**', '*.{rb,yml}')]
+  config.i18n.load_path += Dir[File.join(Rails.root, 'config', 'locales', '**', '*.{rb,yml}')]
 </ruby>
 
 Do check the "Rails i18n Wiki":http://rails-i18n.org/wiki for list of tools available for managing translations.
-- 
cgit v1.2.3


From 3f0097c7157e4a328f87cdf80ab6330c39b6d90f Mon Sep 17 00:00:00 2001
From: Anil Wadghule <anildigital@gmail.com>
Date: Tue, 13 Apr 2010 00:56:34 +0530
Subject: Updated guide to use 'Rails.root.join' to construct path

---
 railties/guides/source/i18n.textile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'railties/guides/source/i18n.textile')

diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile
index 9e882bc0a1..cfaa573fa0 100644
--- a/railties/guides/source/i18n.textile
+++ b/railties/guides/source/i18n.textile
@@ -103,7 +103,7 @@ The default +environment.rb+ files has instructions on how to add locales from a
 # The internationalization framework can be changed
 # to have another default locale (standard is :en) or more load paths.
 # All files from config/locales/*.rb,yml are added automatically.
-# config.i18n.load_path << Dir[File.join(Rails.root, 'my', 'locales', '*.{rb,yml}')]
+# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
 # config.i18n.default_locale = :de
 </ruby>
 
@@ -117,8 +117,7 @@ To tell the I18n library where it can find your custom translation files you can
 # in config/initializers/locale.rb
 
 # tell the I18n library where to find your translations
-I18n.load_path << Dir[ File.join(Rails.root, 'lib', 'locale', 
-  '*.{rb,yml}') ]
+I18n.load_path << Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')]
 
 # set default locale to something other than :en
 I18n.default_locale = :pt
@@ -423,7 +422,8 @@ NOTE: The default locale loading mechanism in Rails does not load locale files i
 
 <ruby>
   # config/environment.rb
-  config.i18n.load_path += Dir[File.join(Rails.root, 'config', 'locales', '**', '*.{rb,yml}')]
+  config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
+
 </ruby>
 
 Do check the "Rails i18n Wiki":http://rails-i18n.org/wiki for list of tools available for managing translations.
-- 
cgit v1.2.3


From fe0b52befb99e247c5cb98aceaa660dce34cfc47 Mon Sep 17 00:00:00 2001
From: Anil Wadghule <anildigital@gmail.com>
Date: Tue, 13 Apr 2010 12:25:44 +0530
Subject: Changes in guide as per Rails 3 features

---
 railties/guides/source/i18n.textile | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

(limited to 'railties/guides/source/i18n.textile')

diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile
index cfaa573fa0..01e3380ee4 100644
--- a/railties/guides/source/i18n.textile
+++ b/railties/guides/source/i18n.textile
@@ -97,19 +97,17 @@ The *translations load path* (+I18n.load_path+) is just a Ruby Array of paths to
 
 NOTE: 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.
 
-The default +environment.rb+ files has instructions on how to add locales from another directory and how to set a different default locale. Just uncomment and edit the specific lines.
+The default +application.rb+ files has instructions on how to add locales from another directory and how to set a different default locale. Just uncomment and edit the specific lines.
 
 <ruby>
-# The internationalization framework can be changed
-# to have another default locale (standard is :en) or more load paths.
-# All files from config/locales/*.rb,yml are added automatically.
-# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
+# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
 # config.i18n.default_locale = :de
 </ruby>
 
 h4. Optional: Custom I18n Configuration Setup
 
-For the sake of completeness, let's mention that if you do not want to use the +environment.rb+ file for some reason, you can always wire up things manually, too.
+For the sake of completeness, let's mention that if you do not want to use the +application.rb+ file for some reason, you can always wire up things manually, too.
 
 To tell the I18n library where it can find your custom translation files you can specify the load path anywhere in your application - just make sure it gets run before any translations are actually looked up. You might also want to change the default locale. The simplest thing possible is to put the following into an initializer:
 
@@ -117,7 +115,7 @@ To tell the I18n library where it can find your custom translation files you can
 # in config/initializers/locale.rb
 
 # tell the I18n library where to find your translations
-I18n.load_path << Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')]
+I18n.load_path += Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')]
 
 # set default locale to something other than :en
 I18n.default_locale = :pt
@@ -125,7 +123,7 @@ I18n.default_locale = :pt
 
 h4. Setting and Passing the Locale
 
-If you want to translate your Rails application to a *single language other than English* (the default locale), you can set I18n.default_locale to your locale in +environment.rb+ or an initializer as shown above, and it will persist through the requests.
+If you want to translate your Rails application to a *single language other than English* (the default locale), you can set I18n.default_locale to your locale in +application.rb+ or an initializer as shown above, and it will persist through the requests.
 
 However, you would probably like to *provide support for more locales* in your application. In such case, you need to set and pass the locale between requests.
 
@@ -226,21 +224,23 @@ You probably want URLs to look like this: +www.example.com/en/books+ (which load
 
 <ruby>
 # config/routes.rb
-map.resources :books, :path_prefix => '/:locale'
+scope "/:locale" do
+  resources :books
+end
 </ruby>
 
 Now, when you call the +books_path+ method you should get +"/en/books"+ (for the default locale). An URL like +http://localhost:3001/nl/books+ should load the Netherlands locale, then, and following calls to +books_path+ should return +"/nl/books"+ (because the locale changed).
 
-Of course, you need to take special care of the root URL (usually "homepage" or "dashboard") of your application. An URL like +http://localhost:3001/nl+ will not work automatically, because the +map.root :controller => "dashboard"+ declaration in your +routes.rb+ doesn't take locale into account. (And rightly so: there's only one "root" URL.)
+Of course, you need to take special care of the root URL (usually "homepage" or "dashboard") of your application. An URL like +http://localhost:3001/nl+ will not work automatically, because the +root :to => "books#index"+ declaration in your +routes.rb+ doesn't take locale into account. (And rightly so: there's only one "root" URL.)
 
 You would probably need to map URLs like these:
 
 <ruby>
 # config/routes.rb
-map.dashboard '/:locale', :controller => "dashboard"
+match '/:locale' => 'dashboard#index'
 </ruby>
 
-Do take special care about the *order of your routes*, so this route declaration does not "eat" other ones. (You may want to add it directly before the +map.root+ declaration.)
+Do take special care about the *order of your routes*, so this route declaration does not "eat" other ones. (You may want to add it directly before the +root :to+ declaration.)
 
 IMPORTANT: This solution has currently one rather big *downside*. Due to the _default_url_options_ implementation, you have to pass the +:id+ option explicitly, like this: +link_to 'Show', book_url(:id => book)+ and not depend on Rails' magic in code like +link_to 'Show', book+. If this should be a problem, have a look at two plugins which simplify work with routes in this way: Sven Fuchs's "routing_filter":http://github.com/svenfuchs/routing-filter/tree/master and Raul Murciano's "translate_routes":http://github.com/raul/translate_routes/tree/master. See also the page "How to encode the current locale in the URL":http://rails-i18n.org/wiki/wikipages/how-to-encode-the-current-locale-in-the-url in the Rails i18n Wiki.
 
@@ -287,8 +287,8 @@ You most probably have something like this in one of your applications:
 
 <ruby>
 # config/routes.rb
-ActionController::Routing::Routes.draw do |map|
-  map.root :controller => 'home', :action => 'index'
+Yourapp::Application.routes.draw do |map|
+  root :to => "home#index"
 end
 
 # app/controllers/home_controller.rb
@@ -421,7 +421,7 @@ This way, you can separate model and model attribute names from text inside view
 NOTE: The default locale loading mechanism in Rails does not load locale files in nested dictionaries, like we have here. So, for this to work, we must explicitly tell Rails to look further:
 
 <ruby>
-  # config/environment.rb
+  # config/application.rb
   config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
 
 </ruby>
-- 
cgit v1.2.3

