diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d83690e..cdc2f59 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,4 +2,10 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + + before_action :set_locale + + def set_locale + I18n.locale = params[:locale] || I18n.default_locale + end end diff --git a/app/views/static_pages/home.html.erb b/app/views/static_pages/home.html.erb index 00df61b..11a091b 100644 --- a/app/views/static_pages/home.html.erb +++ b/app/views/static_pages/home.html.erb @@ -1,6 +1,6 @@
<%= link_to "Books", books_path, class: "btn btn-lg btn-primary", remote: true %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 0653957..30f3f0f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -21,3 +21,5 @@ en: hello: "Hello world" + library: "Library" + welcome_count: "Browse %{count} books" diff --git a/config/locales/fr.yml b/config/locales/fr.yml new file mode 100644 index 0000000..a836b2a --- /dev/null +++ b/config/locales/fr.yml @@ -0,0 +1,4 @@ +fr: + hello: "Bonjour" + library: "Bibliothèque" + welcome_count: "Parcourir les %{count} livres"