mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 01:21:23 +08:00
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:
@ -53,7 +53,7 @@ RSpec.describe Middleware::AnonymousCache do
|
||||
end
|
||||
end
|
||||
|
||||
context "with header-based locale locale" do
|
||||
context "with header or cookie based custom locale" do
|
||||
it "handles different languages" do
|
||||
# Normally does not check the language header
|
||||
french1 = new_helper("HTTP_ACCEPT_LANGUAGE" => "fr").cache_key
|
||||
@ -76,6 +76,9 @@ RSpec.describe Middleware::AnonymousCache do
|
||||
expect(none).to eq(english)
|
||||
expect(french1).to eq(french2)
|
||||
expect(french1).not_to eq(none)
|
||||
|
||||
SiteSetting.set_locale_from_cookie = true
|
||||
expect(new_helper("HTTP_COOKIE" => "locale=es;").cache_key).to include("l=es")
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user