mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
[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.
This commit is contained in:
parent
ad6e8a2fec
commit
451f433205
1 changed files with 11 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue