8000 [HttpKernel] Use Accept-Language header even if there are no enabled locales by MatTheCat · Pull Request #47377 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] Use Accept-Language header even if there are no enabled locales #47377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[HttpKernel] Use Accept-Language header even if there are no enabled …
…locales
  • Loading branch information
MatTheCat authored and fabpot committed Sep 23, 2022
commit b20d074f664e81164ee8b68010831280a218cd41
3 changes: 2 additions & 1 deletion src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ CHANGELOG
`workflow.state_machine`
* Add `rate_limiter` configuration option to `messenger.transport` to allow rate limited transports using the RateLimiter component
* Remove `@internal` tag from secret vaults to allow them to be used directly outside the framework bundle and custom vaults to be added
* Deprecate "framework.form.legacy_error_messages" config node
* Deprecate `framework.form.legacy_error_messages` config node
* Set locale from request rather than default locale if `framework.enabled_locales` is empty and `framework.set_locale_from_accept_language` is true

6.1
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private function setLocale(Request $request)
{
if ($locale = $request->attributes->get('_locale')) {
$request->setLocale($locale);
} elseif ($this->useAcceptLanguageHeader && $this->enabledLocales && ($preferredLanguage = $request->getPreferredLanguage($this->enabledLocales))) {
} elseif ($this->useAcceptLanguageHeader && ($preferredLanguage = $request->getPreferredLanguage($this->enabledLocales))) {
$request->setLocale($preferredLanguage);
$request->attributes->set('_vary_by_language', true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function testRequestNoLocaleFromAcceptLanguageHeader()

$listener->setDefaultLocale($event);
$listener->onKernelRequest($event);
$this->assertEquals('de', $request->getLocale());
$this->assertEquals('fr_FR', $request->getLocale());
}

public function testRequestAttributeLocaleNotOverridenFromAcceptLanguageHeader()
Expand Down
0