-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Documentation is confusing about use of {placeholders} in translations #19593
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
Comments
It seems to be even worse than that. Apparently, this:
will not replace occurrences of the string That is, the second argument passed to This isn't mentioned in the documentation, nor does it explain how this interferes with messages that do use the ICU format. |
I think there is/may be typo indeed here |
I'm not sure. Could it be that:
In fact I'm pretty sure the second half is true (the source code seems to be using
Do you use the ICU format? |
I use icu in some of them, mostly with twig; after i upgraded from older logic |
I've checked and I use things like the doc # emails+intl-icu.fr.yaml
proposition_accepted_user.subject: "{company_name} - foo bar n°{number}" {{ 'proposition_accepted_user.subject'|trans({
'company_name': 'from.name'|trans({}, locale = locale),
'number': number
}, locale = locale) }} so to me I only use the "full" ICU logic now, I was confusing probably with old maner |
Yes, the built-in non-standard Symfony way for translations is not documented. For the not ICU MessageFormat filenames, you can use Twig like placeholders:
The Translator engine will replace everything so this would work also:
The same about pluralization which was documented in the Symfony 1. Currently, it's still in the code and tests, but not documented or deprecated.
The var must be named There is only a note about ranges, but they still work. ICU MessageFormat is standardized and covers more cases like genders. Only ranges are missing. @javiereguiluz The Translator documentation is based on normal file name examples, so why this is not documented? |
I was looking at the documentation about translations here:
https://symfony.com/doc/5.x/translation.html#basic-translation
and I was looking for the part about parameters, or should I say placeholders. What I mean with parameters/placeholders is when you have a phrase
somephrase
whose translation is"Hello {username}
and you call:ane the result is
"Hello John"
.I think those are called Placeholders.
So, the only place where the page above says something about that is here:
https://symfony.com/doc/5.x/translation.html#message-format
So, I follow that link and it says:
and then it explains, among other things, how placeholders work, besides pluralization and other stuff.
This seems to be very clear: in order to use placeholders, as well as pluralization and other features, the message domains has to be suffixed with
+intl-icu
However, I have tried using basic translations with placeholders with the default domain
messages
without any suffix, and placeholders work. I don't know about pluralization and other stuff.So, the documentation wrongly suggests that, in order to be able to use placeholders, you need to suffix the domain names with that string, but that's not true.
I don't know if that's true for other features such as pluralization; if that's the case, then it's not clear.
The text was updated successfully, but these errors were encountered: