aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorJuanito Fatas <katehuang0320@gmail.com>2013-09-09 23:47:38 +0800
committerJuanito Fatas <katehuang0320@gmail.com>2013-09-10 01:48:44 +0800
commit451f433205f1bbe1163475388e87f3a918e5231f (patch)
treefa70e5d7da792d2a22b17097c0de98aaac68d824 /guides
parentad6e8a2fec552bf239cb1c059323d93a265c1b18 (diff)
downloadrails-451f433205f1bbe1163475388e87f3a918e5231f.tar.gz
rails-451f433205f1bbe1163475388e87f3a918e5231f.tar.bz2
rails-451f433205f1bbe1163475388e87f3a918e5231f.zip
[ci skip] Add missing setting locale code snippet.
This is for 3 Internationalizing your Application of i18n.md. Missing the code as mentioned in 2.3, setting locale. Without this, the example to add config/locales/pirate.yml will not work.
Diffstat (limited to 'guides')
-rw-r--r--guides/source/i18n.md11
1 files changed, 11 insertions, 0 deletions
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index c191db1df9..e3ca129189 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -316,6 +316,17 @@ end
```
```ruby
+# app/controllers/application_controller.rb
+class ApplicationController < ActionController::Base
+ before_action :set_locale
+
+ def set_locale
+ I18n.locale = params[:locale] || I18n.default_locale
+ end
+end
+```
+
+```ruby
# app/controllers/home_controller.rb
class HomeController < ApplicationController
def index