From 451f433205f1bbe1163475388e87f3a918e5231f Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Mon, 9 Sep 2013 23:47:38 +0800 Subject: [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. --- guides/source/i18n.md | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'guides') 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 @@ -315,6 +315,17 @@ Yourapp::Application.routes.draw do 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 -- cgit v1.2.3