@@ -282,6 +282,87 @@ method.
282
282
You can read more information about the default locale in
283
283
:ref: `translation-default-locale `.
284
284
285
+ .. _reference-enabled-locales :
286
+
287
+ enabled_locales
288
+ ...............
289
+
290
+ **type **: ``array `` **default **: ``[] `` (empty array = enable all locales)
291
+
292
+ .. versionadded :: 5.1
293
+
294
+ The ``enabled_locales `` option was introduced in Symfony 5.1.
295
+
296
+ Symfony applications generate by default the translation files for validation
297
+ and security messages in all locales. If your application only uses some
298
+ locales, use this option to restrict the files generated by Symfony and improve
299
+ performance a bit:
300
+
301
+ .. configuration-block ::
302
+
303
+ .. code-block :: yaml
304
+
305
+ # config/packages/translation.yaml
306
+ framework :
307
+ enabled_locales : ['en', 'es']
308
+
309
+ .. code-block :: xml
310
+
311
+ <!-- config/packages/translation.xml -->
312
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
313
+ <container xmlns =" http://symfony.com/schema/dic/services"
314
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
315
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
316
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
317
+ https://symfony.com/schema/dic/services/services-1.0.xsd
318
+ http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
319
+
320
+ <framework : config >
321
+ <enabled-locale >en</enabled-locale >
322
+ <enabled-locale >es</enabled-locale >
323
+ </framework : config >
324
+ </container >
325
+
326
+ .. code-block :: php
327
+
328
+ // config/packages/translation.php
329
+ use Symfony\Config\FrameworkConfig;
330
+
331
+ return static function (FrameworkConfig $framework) {
332
+ $framework->enabledLocales(['en', 'es']);
333
+ };
334
+
335
+ If some user makes requests with a locale not included in this option, the
336
+ application won't display any error because Symfony will display contents using
337
+ the fallback locale.
338
+
339
+ set_content_language_from_locale
340
+ ...............
341
+
342
+ **type **: ``boolean `` **default **: ``false ``
343
+
344
+ .. versionadded :: 5.4
345
+
346
+ The ``set_content_language_from_locale `` option was introduced in Symfony 5.4.
347
+
348
+ If this option is set to ``true ``, the response will have a ``Content-Language ``
349
+ HTTP header set with the ``Request `` locale.
350
+
351
+ set_locale_from_accept_language
352
+ ...............
353
+
354
+ **type **: ``boolean `` **default **: ``false ``
355
+
356
+ .. versionadded :: 5.4
357
+
358
+ The ``set_locale_from_accept_language `` option was introduced in Symfony 5.4.
359
+
360
+ The ``Request `` locale will automatically be set to the value of the
361
+ ``Accept-Language `` HTTP header.
362
+
363
+ When the ``_locale `` request attribute is passed, the ``Accept-Language `` header
364
+ is ignored.
365
+
285
366
disallow_search_engine_index
286
367
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
287
368
@@ -2142,52 +2223,10 @@ enabled_locales
2142
2223
2143
2224
The ``enabled_locales `` option was introduced in Symfony 5.1.
2144
2225
2145
- Symfony applications generate by default the translation files for validation
2146
- and security messages in all locales. If your application only uses some
2147
- locales, use this option to restrict the files generated by Symfony and improve
2148
- performance a bit:
2149
-
2150
- .. configuration-block ::
2151
-
2152
- .. code-block :: yaml
2153
-
2154
- # config/packages/translation.yaml
2155
- framework :
2156
- translator :
2157
- enabled_locales : ['en', 'es']
2158
-
2159
- .. code-block :: xml
2226
+ .. deprecated :: 5.4
2160
2227
2161
- <!-- config/packages/translation.xml -->
2162
- <?xml version =" 1.0" encoding =" UTF-8" ?>
2163
- <container xmlns =" http://symfony.com/schema/dic/services"
2164
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2165
- xmlns : framework =" http://symfony.com/schema/dic/symfony"
2166
- xsi : schemaLocation =" http://symfony.com/schema/dic/services
2167
- https://symfony.com/schema/dic/services/services-1.0.xsd
2168
- http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
2169
-
2170
- <framework : config >
2171
- <framework : translator >
2172
- <enabled-locale >en</enabled-locale >
2173
- <enabled-locale >es</enabled-locale >
2174
- </framework : translator >
2175
- </framework : config >
2176
- </container >
2177
-
2178
- .. code-block :: php
2179
-
2180
- // config/packages/translation.php
2181
- use Symfony\Config\FrameworkConfig;
2182
-
2183
- return static function (FrameworkConfig $framework) {
2184
- $framework->translator()
2185
- ->enabledLocales(['en', 'es']);
2186
- };
2187
-
2188
- If some user makes requests with a locale not included in this option, the
2189
- application won't display any error because Symfony will display contents using
2190
- the fallback locale.
2228
+ Using `framework.translator.enabled_locales ` has been deprecated in favour of
2229
+ :ref: `framework.enabled_locales <reference-enabled-locales >` since Symfony 5.4.
2191
2230
2192
2231
.. _fallback :
2193
2232
0 commit comments