mirror of https://github.com/Evolix/chexpire.git
Use Rack::Locale to detect locale from HTTP headers
This commit is contained in:
parent
bcd5a02609
commit
58d8bdd98b
2
Gemfile
2
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'
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% # Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr> %>
|
||||
<% # License: GNU AGPL-3+ (see full text in LICENSE file) %>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="<%= I18n.locale %>">
|
||||
<head>
|
||||
<title>Chexpire</title>
|
||||
<%= csrf_meta_tags %>
|
||||
|
|
Loading…
Reference in New Issue