mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Add setting to use browser locale if available (#404)
This commit is contained in:
committed by
GitHub
parent
5decb702f2
commit
2e07f7b00d
@@ -63,6 +63,18 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
# Set tenant locale
|
||||
I18n.locale = @tenant.locale
|
||||
|
||||
if @tenant_setting.use_browser_locale
|
||||
user_preferred_language = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
|
||||
available_locales = I18n.available_locales.map { |locale| locale.to_s[0, 2] }
|
||||
|
||||
if available_locales.include?(user_preferred_language)
|
||||
# special cases
|
||||
user_preferred_language = 'zh-CN' if user_preferred_language == 'zh'
|
||||
|
||||
I18n.locale = user_preferred_language
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def load_oauths
|
||||
|
||||
Reference in New Issue
Block a user