From 48f8eee14d555eb3cfebcc2143119e48b6dd768a Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Fri, 25 Jul 2025 14:28:08 +0200 Subject: [PATCH] Add Static message in doc --- translation.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/translation.rst b/translation.rst index ed656c62848..d3042356b8e 100644 --- a/translation.rst +++ b/translation.rst @@ -337,6 +337,19 @@ Templates are now much simpler because you can pass translatable objects to the There's also a :ref:`function called t() `, available both in Twig and PHP, as a shortcut to create translatable objects. +On the contrary, if you want your message to never be translated, you can +ensure this behavior with the +:class:`Symfony\\Component\\Translation\\StaticMessage` class:: + + use Symfony\Component\Translation\StaticMessage; + + $message = new StaticMessage('This message will never be translated.'); + +.. versionadded:: 7.4 + + The :class:`Symfony\\Component\\Translation\\StaticMessage` class was introduced in Symfony + 7.4. + .. _translation-in-templates: Translations in Templates