diff --git a/Gemfile b/Gemfile index 3a1e905..5230b7d 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,8 @@ gem 'bcrypt', '~> 3.1.7' # Use ActiveStorage variant # gem 'mini_magick', '~> 4.8' +gem 'rack-contrib' + gem 'open4' gem 'naught' gem 'hashie' diff --git a/Gemfile.lock b/Gemfile.lock index 5ed0b75..3278ee9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -214,6 +214,8 @@ GEM pundit (1.1.0) activesupport (>= 3.0.0) rack (2.0.5) + rack-contrib (2.0.1) + rack (~> 2.0) rack-proxy (0.6.4) rack rack-test (1.1.0) @@ -369,6 +371,7 @@ DEPENDENCIES pry-rails puma (~> 3.11) pundit (~> 1.1) + rack-contrib rails (~> 5.2.0) rails-i18n (~> 5.1) rbnacl (>= 3.2, < 5.0) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0af9f21..3fa3d5e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -21,7 +21,9 @@ class ApplicationController < ActionController::Base end def set_locale - I18n.locale = current_user.try(:locale) || I18n.default_locale + I18n.locale = current_user.try(:locale) \ + || request.env["rack.locale"].presence \ + || I18n.default_locale end def not_found diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index de2247f..6e1ecf0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,7 +1,7 @@ <% # Copyright (C) 2018 Colin Darie , 2018 Evolix %> <% # License: GNU AGPL-3+ (see full text in LICENSE file) %> - + Chexpire <%= csrf_meta_tags %> diff --git a/config.ru b/config.ru index 441e6ff..363528a 100644 --- a/config.ru +++ b/config.ru @@ -2,4 +2,6 @@ require_relative "config/environment" +use Rack::Locale + run Rails.application