This commit is contained in:
Meutel 2015-08-04 19:57:48 +02:00
parent 1030170c47
commit 028887f1a2
4 changed files with 14 additions and 2 deletions

View File

@ -2,4 +2,10 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception. # Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead. # For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception protect_from_forgery with: :exception
before_action :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
end end

View File

@ -1,6 +1,6 @@
<div class="center jumbotron"> <div class="center jumbotron">
<h1>Library</h1> <h1><%= t :library %></h1>
<h2>Browse <%= @books_count %> books</h2> <h2><%= t :welcome_count, count: @books_count %></h2>
<p> <p>
<%= link_to "Books", books_path, class: "btn btn-lg btn-primary", remote: true %> <%= link_to "Books", books_path, class: "btn btn-lg btn-primary", remote: true %>

View File

@ -21,3 +21,5 @@
en: en:
hello: "Hello world" hello: "Hello world"
library: "Library"
welcome_count: "Browse %{count} books"

4
config/locales/fr.yml Normal file
View File

@ -0,0 +1,4 @@
fr:
hello: "Bonjour"
library: "Bibliothèque"
welcome_count: "Parcourir les %{count} livres"