Skip to content

Commit 0c048dd

Browse files
committed
added logging to translator.
1 parent 5e7fa55 commit 0c048dd

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

book/translation.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,15 @@ checks translation resources for several different locales:
400400
3. If the translation still isn't found, Symfony uses the ``fallback`` configuration
401401
parameter, which defaults to ``en`` (see `Configuration`_).
402402

403+
.. versionadded:: 2.6
404+
The ability to log missing translations was introduced in Symfony 2.6.
405+
406+
.. note::
407+
408+
When Symfony doesn't find a translation in the given locale, it will
409+
add the missing translation to the log file. For details,
410+
see :ref:`reference-framework-translator-logging`.
411+
403412
.. _book-translation-user-locale:
404413

405414
Handling the User's Locale

reference/configuration/framework.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ Configuration
4848
* `profiler`_
4949
* `collect`_
5050
* :ref:`enabled <profiler.enabled>`
51+
* `translator`_
52+
* :ref:`enabled <translator.enabled>`
53+
* `fallback`_
54+
* `logging`_
5155

5256
secret
5357
~~~~~~
@@ -495,6 +499,42 @@ and activate the data collectors by hand::
495499

496500
$profiler->enable();
497501

502+
translator
503+
~~~~~~~~~~
504+
505+
.. _translator.enabled:
506+
507+
enabled
508+
.......
509+
510+
**type**: ``boolean`` **default**: ``false``
511+
512+
Whether or not to enable the ``translator`` service in the service container.
513+
514+
fallback
515+
........
516+
517+
**default**: ``en``
518+
519+
This option is used when the translation key for the current locale wasn't found.
520+
521+
For more details, see :doc:`/book/translation`.
522+
523+
.. _reference-framework-translator-logging:
524+
525+
logging
526+
.......
527+
528+
.. versionadded:: 2.6
529+
The ``logging`` option was introduced in Symfony 2.6.
530+
531+
**default**: ``true`` when the debug mode is enabled, ``false`` otherwise.
532+
533+
When ``true``, a log entry is made whenever the translator cannot find a translation
534+
for a given key. The logs are made to the ``translation`` channel and at the ``debug``
535+
for level for keys where there is a translation in the fallback locale and the ``warning``
536+
level if there is no translation to use at all.
537+
498538
Full default Configuration
499539
--------------------------
500540

@@ -612,6 +652,7 @@ Full default Configuration
612652
translator:
613653
enabled: false
614654
fallback: en
655+
logging: "%kernel.debug%"
615656
616657
# validation configuration
617658
validation:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy