mirror of
https://github.com/Evolix/chexpire.git
synced 2024-04-26 05:50:50 +02:00
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
|
# Use ActiveStorage variant
|
||||||
# gem 'mini_magick', '~> 4.8'
|
# gem 'mini_magick', '~> 4.8'
|
||||||
|
|
||||||
|
gem 'rack-contrib'
|
||||||
|
|
||||||
gem 'open4'
|
gem 'open4'
|
||||||
gem 'naught'
|
gem 'naught'
|
||||||
gem 'hashie'
|
gem 'hashie'
|
||||||
|
|
|
@ -214,6 +214,8 @@ GEM
|
||||||
pundit (1.1.0)
|
pundit (1.1.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
rack (2.0.5)
|
rack (2.0.5)
|
||||||
|
rack-contrib (2.0.1)
|
||||||
|
rack (~> 2.0)
|
||||||
rack-proxy (0.6.4)
|
rack-proxy (0.6.4)
|
||||||
rack
|
rack
|
||||||
rack-test (1.1.0)
|
rack-test (1.1.0)
|
||||||
|
@ -369,6 +371,7 @@ DEPENDENCIES
|
||||||
pry-rails
|
pry-rails
|
||||||
puma (~> 3.11)
|
puma (~> 3.11)
|
||||||
pundit (~> 1.1)
|
pundit (~> 1.1)
|
||||||
|
rack-contrib
|
||||||
rails (~> 5.2.0)
|
rails (~> 5.2.0)
|
||||||
rails-i18n (~> 5.1)
|
rails-i18n (~> 5.1)
|
||||||
rbnacl (>= 3.2, < 5.0)
|
rbnacl (>= 3.2, < 5.0)
|
||||||
|
|
|
@ -21,7 +21,9 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_locale
|
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
|
end
|
||||||
|
|
||||||
def not_found
|
def not_found
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<% # Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr> %>
|
<% # Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr> %>
|
||||||
<% # License: GNU AGPL-3+ (see full text in LICENSE file) %>
|
<% # License: GNU AGPL-3+ (see full text in LICENSE file) %>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="<%= I18n.locale %>">
|
||||||
<head>
|
<head>
|
||||||
<title>Chexpire</title>
|
<title>Chexpire</title>
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
|
|
Loading…
Reference in a new issue