Skip to content

Commit d463334

Browse files
committed
Add twig reference docs for the t() function
1 parent cc913f0 commit d463334

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

reference/twig_reference.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,27 @@ impersonation_exit_url
304304
It's similar to the `impersonation_exit_path`_ function, but it generates
305305
absolute URLs instead of relative URLs.
306306

307+
t
308+
~
309+
310+
.. code-block:: twig
311+
312+
{{ t(message, parameters = [], domain = 'messages')|trans }}
313+
314+
``message``
315+
**type**: ``string``
316+
``parameters`` *(optional)*
317+
**type**: ``array`` **default**: ``[]``
318+
``domain`` *(optional)*
319+
**type**: ``string`` **default**: ``messages``
320+
321+
.. versionadded:: 5.2
322+
323+
The ``t()`` function was introduced in Symfony 5.2.
324+
325+
Creates a ``Translatable`` object that can be passed to the
326+
:ref:`trans filter <reference-twig-filter-trans>`.
327+
307328
Form Related Functions
308329
~~~~~~~~~~~~~~~~~~~~~~
309330

@@ -341,6 +362,8 @@ Makes a technical name human readable (i.e. replaces underscores by spaces
341362
or transforms camelCase text like ``helloWorld`` to ``hello world``
342363
and then capitalizes the string).
343364

365+
.. _reference-twig-filter-trans:
366+
344367
trans
345368
~~~~~
346369

@@ -357,6 +380,10 @@ trans
357380
``locale`` *(optional)*
358381
**type**: ``string`` **default**: ``null``
359382

383+
.. versionadded:: 5.2
384+
385+
``message`` accepting ``Translatable`` as a valid type was introduced in Symfony 5.2.
386+
360387
Translates the text into the current language. More information in
361388
:ref:`Translation Filters <translation-filters>`.
362389

0 commit comments

Comments
 (0)