Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

f:translate contains bad example - ordering is not explained #84

Closed
Padina42 opened this issue May 5, 2024 · 3 comments
Closed

f:translate contains bad example - ordering is not explained #84

Padina42 opened this issue May 5, 2024 · 3 comments

Comments

@Padina42
Copy link

Padina42 commented May 5, 2024

I could not change it directly.

Bad example:

{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::

Some text about a %s and a %s.

The output will be "Some text about a dog and a fox".

Better example

Bad example:
{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 or ordered %1$s conversions (:php:sprintf()) in the language file::

Some text about a %2$s being smaller than a %1$s.

The output will be "Some text about a fox being smaller than a dog".

@garvinhicking
Copy link
Contributor

garvinhicking commented May 6, 2024

The ViewHelper docs are actually part of the fluid repository, which is why you probably couldn't easily create a PR for it.

Good suggestion to enhance this.
Personally I wouldn't change the example to be more complicated, but rather adjust the sentence that points to sprintf, and state something like: "You can also use placeholders for ordering arguments loke %1$s or other formatting like %d and %f, as outlined in the PHP documentation for sprintf (link)"?

Would you like to create a PR/issue in the repo https://github.com/TYPO3/Fluid or should I?

@Padina42
Copy link
Author

Padina42 commented May 7, 2024

You can do it. That sentence will although do it.

@garvinhicking
Copy link
Contributor

Created a Forge issue and Gerritt patch (it's in the core of course, not the external typo3/fluid package):

https://review.typo3.org/c/Packages/TYPO3.CMS/+/84183
https://forge.typo3.org/issues/103808

Closing issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants