You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #43108 [HttpKernel] Add basic support for language negotiation (GregoireHebert)
This PR was merged into the 5.4 branch.
Discussion
----------
[HttpKernel] Add basic support for language negotiation
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Continuation of #36507. Thanks `@GregoireHebert`!
This PR adds two options to the framework configuration:
- `set_locale_from_accept_language`: Makes the `Request`' locale automatically set based on the `Accept-Language` header (restricted by a new `framework.enabled_locales` config option which replaces `framework.translator.enabled_locales`).
The explicit `_locale` request attribute always wins over the `Accept-Language` header when it's set.
- `set_content_language_from_locale`: Sets the `Content-Language` Response header based on the `Request`' locale.
This is going to be useful for API Platform and related (e.g. Sylius/Sylius#11412).
Commits
-------
904b54f [HttpKernel] Add basic support for language negotiation
Copy file name to clipboardExpand all lines: UPGRADE-6.0.md
+1
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,7 @@ Form
89
89
FrameworkBundle
90
90
---------------
91
91
92
+
* Remove the `framework.translator.enabled_locales` config option, use `framework.enabled_locales` instead
92
93
* Remove the `session.storage` alias and `session.storage.*` services, use the `session.storage.factory` alias and `session.storage.factory.*` services instead
93
94
* Remove `framework.session.storage_id` configuration option, use the `framework.session.storage_factory_id` configuration option instead
94
95
* Remove the `session` service and the `SessionInterface` alias, use the `\Symfony\Component\HttpFoundation\Request::getSession()` or the new `\Symfony\Component\HttpFoundation\RequestStack::getSession()` methods instead
->info('Whether to use the Accept-Language HTTP header to set the Request locale (only when the "_locale" request attribute is not passed).')
92
+
->defaultFalse()
93
+
->end()
94
+
->booleanNode('set_content_language_from_locale')
95
+
->info('Whether to set the Content-Language HTTP header on the Response using the Request locale.')
96
+
->defaultFalse()
97
+
->end()
98
+
->arrayNode('enabled_locales')
99
+
->info('Defines the possible locales for the application. This list is used for generating translations files, but also to restrict which locales are allowed when it is set from Accept-Language header (using "set_locale_from_accept_language").')
0 commit comments