71. app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
helper :all
protect_from_forgery
before_filter :set_locale
private
def set_locale
I18n.locale = params[:locale] if params[:locale]
end
end
Tuesday, April 7, 2009
72. app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
helper :all
protect_from_forgery
before_filter :set_locale
private
def set_locale
I18n.locale = params[:locale] if params[:locale]
end
end
Tuesday, April 7, 2009
111. ./script/generate controller page
class PageController < ApplicationController
def show
render :template => params[:id]
end
end
Tuesday, April 7, 2009
112. ./script/generate controller page
class PageController < ApplicationController
def show
render :template => params[:id]
end
end
app/views/page/_header.html.erb
app/views/page/about.html.erb
Tuesday, April 7, 2009
116. app/views/page/about.html.erb
<%= render :partial => quot;headerquot; %>
<p>Faster than a bullet<br/>
Terrifying scream<br/>
Enraged and full of anger<br/>
He’s half man and half machine</p>
Tuesday, April 7, 2009
117. app/views/page/about.html.erb
<%= render :partial => quot;headerquot; %>
<p>Faster than a bullet<br/>
Terrifying scream<br/>
Enraged and full of anger<br/>
He’s half man and half machine</p>
app/views/page/about.pt-BR.html.erb
<%= render :partial => quot;headerquot; %>
<p>Mais rápido que uma bala<br/>
Um grito apavorante<br/>
Enfurecido e cheio de raiva<br/>
Ele é metade homem, metade máquina</p>
Tuesday, April 7, 2009
118. app/views/page/about.html.erb
<%= render :partial => quot;headerquot; %>
<p>Faster than a bullet<br/>
Terrifying scream<br/>
Enraged and full of anger<br/>
He’s half man and half machine</p>
app/views/page/about.pt-BR.html.erb
<%= render :partial => quot;headerquot; %>
<p>Mais rápido que uma bala<br/>
Um grito apavorante<br/>
Enfurecido e cheio de raiva<br/>
Ele é metade homem, metade máquina</p>
Tuesday, April 7, 2009
119. app/views/page/about.html.erb
<%= render :partial => quot;headerquot; %>
<p>Faster than a bullet<br/>
Terrifying scream<br/>
Enraged and full of anger<br/>
He’s half man and half machine</p>
app/views/page/about.pt-BR.html.erb
<%= render :partial => quot;headerquot; %>
<p>Mais rápido que uma bala<br/>
Um grito apavorante<br/>
Enfurecido e cheio de raiva<br/>
Ele é metade homem, metade máquina</p>
Tuesday, April 7, 2009
120. app/views/page/_header.html.erb
<% title quot;Official Rails I18n Project Hymnquot; %>
<h3>Judas Priest - Painkiller</h3>
app/views/page/_header.pt-BR.erb
<% title quot;Hino Oficial do Projeto Rails I18nquot; %>
<h3>Judas Priest - Painkiller</h3>
Tuesday, April 7, 2009
126. ./script/plugin install git://github.com/iain/http_accept_language.git
app/controllers/application_controller.rb
def set_locale
# comment the next line to disable http_accept_language
recognition
params[:locale] = request.compatible_language_from(
I18n.available_locales) unless params[:locale]
I18n.locale = params[:locale] if params[:locale]
end
Tuesday, April 7, 2009
127. ./script/plugin install git://github.com/iain/http_accept_language.git
app/controllers/application_controller.rb
def set_locale
# comment the next line to disable http_accept_language
recognition
params[:locale] = request.compatible_language_from(
I18n.available_locales) unless params[:locale]
I18n.locale = params[:locale] if params[:locale]
end
Tuesday, April 7, 2009