FEATURE: new site setting to set locale from cookie for anonymous users. (#18377)

This new hidden default-disabled site setting `set_locale_from_cookie` will set locale from anonymous user's cookie value.
This commit is contained in:
Vinoth Kannan
2022-09-27 14:26:06 +05:30
committed by GitHub
parent 0b6c89dc62
commit 076abe46fa
6 changed files with 57 additions and 12 deletions

View File

@ -400,11 +400,8 @@ class ApplicationController < ActionController::Base
if check_current_user && (user = current_user rescue nil)
locale = user.effective_locale
else
if SiteSetting.set_locale_from_accept_language_header
locale = locale_from_header
else
locale = SiteSetting.default_locale
end
locale = Discourse.anonymous_locale(request)
locale ||= SiteSetting.default_locale
end
if !I18n.locale_available?(locale)
@ -624,10 +621,6 @@ class ApplicationController < ActionController::Base
private
def locale_from_header
HttpLanguageParser.parse(request.env["HTTP_ACCEPT_LANGUAGE"])
end
def preload_anonymous_data
store_preloaded("site", Site.json_for(guardian))
store_preloaded("siteSettings", SiteSetting.client_settings_json)