Skip to content

Commit 00cf7e6

Browse files
committed
minor #18726 [Serializer] Add TranslatableNormalizer (alexandre-daubois)
This PR was merged into the 6.4 branch. Discussion ---------- [Serializer] Add `TranslatableNormalizer` Fix #18665 Commits ------- 3a31df7 [Serializer] Add `TranslatableNormalizer`
2 parents b5e83d0 + 3a31df7 commit 00cf7e6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

components/serializer.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,20 @@ The Serializer component provides several built-in normalizers:
882882
Also it can denormalize ``uuid`` or ``ulid`` strings to :class:`Symfony\\Component\\Uid\\Uuid`
883883
or :class:`Symfony\\Component\\Uid\\Ulid`. The format does not matter.
884884

885+
:class:`Symfony\\Component\\Serializer\\Normalizer\\TranslatableNormalizer`
886+
This normalizer converts objects that implement
887+
:class:`Symfony\\Contracts\\Translation\\TranslatableInterface` into
888+
translated strings, using the
889+
:method:`Symfony\\Contracts\\Translation\\TranslatableInterface::trans`
890+
method. You can define the locale to use to translate the object by
891+
setting the ``TranslatableNormalizer::NORMALIZATION_LOCALE_KEY`` serializer
892+
context option.
893+
894+
.. versionadded:: 6.4
895+
896+
The :class:`Symfony\\Component\\Serializer\\Normalizer\\TranslatableNormalizer`
897+
was introduced in Symfony 6.4.
898+
885899
.. note::
886900

887901
You can also create your own Normalizer to use another structure. Read more at

serializer.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ As well as the following normalizers:
7575
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ConstraintViolationListNormalizer`
7676
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer`
7777
* :class:`Symfony\\Component\\Serializer\\Normalizer\\BackedEnumNormalizer`
78+
* :class:`Symfony\\Component\\Serializer\\Normalizer\\TranslatableNormalizer`
7879

7980
Other :ref:`built-in normalizers <component-serializer-normalizers>` and
8081
custom normalizers and/or encoders can also be loaded by tagging them as

0 commit comments

Comments
 (0)