From b4b18cd569284ecd4a3e3b3bd550af628a21374a Mon Sep 17 00:00:00 2001 From: Feliciaan De Palmenaer Date: Sun, 29 Jan 2017 13:32:29 +0100 Subject: [PATCH 1/5] Add locale --- app/controllers/application_controller.rb | 9 +++++++++ app/views/layouts/_login.html.erb | 6 ++++++ app/views/registrations/_basic.html.erb | 2 +- config/locales/en.yml | 1 + config/locales/nl.yml | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e0b73800..112693a6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,6 +5,15 @@ class ApplicationController < ActionController::Base after_filter :store_location + before_action :set_locale + + def set_locale + I18n.locale = params[:locale] || session[:locale] || I18n.default_locale + if params[:locale] + session[:locale] = params[:locale] + end + end + def store_location # store last url as long as it isn't a /users path session[:previous_url] = request.fullpath unless request.fullpath =~ /\/users/ diff --git a/app/views/layouts/_login.html.erb b/app/views/layouts/_login.html.erb index f6076958..eb719d1f 100644 --- a/app/views/layouts/_login.html.erb +++ b/app/views/layouts/_login.html.erb @@ -1,4 +1,10 @@