Skip to content
Snippets Groups Projects
Commit 658dab4f authored by Garvin Hicking's avatar Garvin Hicking Committed by Lina Wolf
Browse files

[DOCS] Add sprintf() reference to f:translate ViewHelper documentation

The ViewHelper documentation for f:translate mentioned
sprintf() from PHP, but did not link to it.

This patch adds a link and also optimizes markup, plus a few more
sprintf() examples with ordered parameters and number formatting.

See forge issue for screenshots how this looks before and
after the change.

Resolves: #103808
Releases: main, 12.4
Change-Id: I237d4b668291ad68bf083e35c0bdf6510158b38b
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84183


Reviewed-by: default avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: default avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: default avatarcore-ci <typo3@b13.com>
Reviewed-by: default avatarLina Wolf <112@linawolf.de>
Tested-by: default avatarLina Wolf <112@linawolf.de>
parent 16b63a18
Branches
Tags
No related merge requests found
......@@ -82,16 +82,22 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
* {f:translate(key: 'someKey', arguments: {0: 'dog', 1: 'fox'}, default: 'default value')}
*
* Value of key ``someKey`` in the current website language
* with the given arguments (“dog” and “fox”) assigned for the specified
* ``%s`` conversions (:php:`sprintf()`) in the language file::
* with the given arguments (``dog`` and ``fox``) assigned for the specified
* ``%s`` conversions, using `PHP sprintf() notation <https://www.php.net/sprintf>`__ in the
* language file::
*
* <trans-unit id="someKey" resname="someKey">
* <source>Some text about a %s and a %s.</source>
* </trans-unit>
*
* The output will be "Some text about a dog and a fox".
* The output will be :html:`Some text about a dog and a fox`.
*
* If the key ``someKey`` is not found in the language file, the output is “default value”.
* If the key ``someKey`` is not found in the language file, the output is :html:`default value`.
*
* As in PHP's :php:`sprintf()` you can order placeholders (:php:`Second %2$s, first %1$s`)
* or use specific types like :php:`A padded number: %'.09d`, returning ``000000123`` for a number
* passed as ``123``.
* See the `sprintf`_ PHP Documentation for more information on possible formatting.
*
* Inline notation with extension name
* -----------------------------------
......@@ -102,6 +108,8 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
*
* Value of key ``someKey`` in the current website language.
* The locallang file of extension "some_extension_name" will be used.
*
* .. _parseFunc: https://www.php.net/sprintf
*/
final class TranslateViewHelper extends AbstractViewHelper
{
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment