mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 15:31:11 +08:00
FEATURE: Allow setting locale from 'lang' param (#30952)
As we start to translate more pages, we'll need a way for other sites to link back to our translated topics. This commit gives us the ability to use the "lang" URL param to define what language a site should be in. Related: https://github.com/discourse/discourse-translator/pull/199
This commit is contained in:
@ -1215,13 +1215,11 @@ module Discourse
|
||||
end
|
||||
|
||||
def self.anonymous_locale(request)
|
||||
locale =
|
||||
HttpLanguageParser.parse(request.cookies["locale"]) if SiteSetting.set_locale_from_cookie
|
||||
locale = request.params["lang"] if SiteSetting.set_locale_from_param
|
||||
locale ||= request.cookies["locale"] if SiteSetting.set_locale_from_cookie
|
||||
locale ||=
|
||||
HttpLanguageParser.parse(
|
||||
request.env["HTTP_ACCEPT_LANGUAGE"],
|
||||
) if SiteSetting.set_locale_from_accept_language_header
|
||||
locale
|
||||
request.env["HTTP_ACCEPT_LANGUAGE"] if SiteSetting.set_locale_from_accept_language_header
|
||||
HttpLanguageParser.parse(locale)
|
||||
end
|
||||
|
||||
# For test environment only
|
||||
|
Reference in New Issue
Block a user