Bug #37387
Translate Helper: Arguments replacement is not working for default value
Status: | Resolved | Start date: | 2012-05-22 | |
---|---|---|---|---|
Priority: | Must have | Due date: | ||
Assigned To: | Karsten Dambekalns | % Done: | 100% |
|
Category: | ViewHelpers | |||
Target version: | TYPO3 Flow Base Distribution - 1.1 RC2 | |||
Has patch: | No | Affected Flow version: | FLOW3 1.1.0 beta 1 |
Description
I have following tag and there is no translation in xliff file yet for key 'something'
<f:translate id="something" arguments="{0: 'test'}">You haven't created a {0}, yet</f:translate>
Expected behavior would be that it will output:
You haven't created a test, yet
But argument replacement is not working for default message and output is now:
You haven't created a , yet
Associated revisions
[BUGFIX] Replace placeholders in fallback for id translation
When using id based translation and no translation is defined in XLIFF,
the tag value is used as a fallback in TranslateViewHelper.
With this change, the fallback is passed to label based translation,
making placeholder replacement work also if no translation does exist
yet.
Change-Id: If812e7ae968a247e7f1a075f1eb0f7ff97982eab
Fixes: #37387
Releases: 1.1, 1.2
[BUGFIX] Replace placeholders in fallback for id translation
When using id based translation and no translation is defined in XLIFF,
the tag value is used as a fallback in TranslateViewHelper.
With this change, the fallback is passed to label based translation,
making placeholder replacement work also if no translation does exist
yet.
Change-Id: If812e7ae968a247e7f1a075f1eb0f7ff97982eab
Fixes: #37387
Releases: 1.1, 1.2
History
#1 Updated by Karsten Dambekalns about 3 years ago
- Status changed from New to Accepted
- Assigned To set to Karsten Dambekalns
- Target version set to 1.1 beta 2
#2 Updated by Karsten Dambekalns about 3 years ago
- Status changed from Accepted to Needs Feedback
- Target version changed from 1.1 beta 2 to 1.1
Right, but the fact that there is output is rather due to the fact that the VH itself does:
$originalLabel = $value === NULL ? $this->renderChildren() : $value; … $translation = $this->translator->translateById($id, $arguments, $quantity, $localeObject, $source, $package); if ($translation === $id) { return $originalLabel; } else { …
So this is not really a "default value" but more a fallback - and doing placeholder resolving is anything but trivial (see FormatResolver->resolvePlaceholders
).
#3 Updated by Krzysztof Daniel about 3 years ago
So what do you suggest? That this "translation by label" that shall be supported same way as by key and in my opinion even if label is not in translation files yet, placeholders shall be replaced.
#4 Updated by Krzysztof Daniel about 3 years ago
Any update on this?
#5 Updated by Bastian Waidelich about 3 years ago
Krzysztof Daniel wrote:
I have following tag and there is no translation in xliff file yet for key 'something'
<f:translate id="something" arguments="{0: 'test'}">You haven't created a {0}, yet</f:translate>
Expected behavior would be that it will output:
You haven't created a test, yet
Do you have a valid use case for this? Why not just type
1<f:translate id="something" arguments="{0: 'test'}">You haven't created a test, yet</f:translate>
?
#6 Updated by Krzysztof Daniel about 3 years ago
Because the value comes form variable.
<f:translate id="something" arguments="{0: '{username}'}">Hello {0}</f:translate>
I could do something like
<f:translate arguments="{0: '{username}'}">Hello {username}</f:translate>
But than translation by label would not work properly.
#7 Updated by Bastian Waidelich about 3 years ago
Krzysztof Daniel wrote:
<f:translate arguments="{0: '{username}'}">Hello {username}</f:translate>
But than translation by label would not work properly.
I see, that makes sense. In that case it should work though (not specifying the id argument) - did you test it?
#8 Updated by Krzysztof Daniel about 3 years ago
But those are workarounds. Expected behavior shall be unified.
And if you look into real life example:
<f:translate id="notification.sender_and_date" arguments="{0: '{notification.sender}', 1: '{notification.createdAt -> f:format.date(format:\'d-m-Y H:i\')}'}">{notification.sender} {notification.createdAt -> f:format.date(format:'d-m-Y H:i')}</f:translate>
Execution of those helper multiple times is reaaaaaaly bad.
To make it work properly I expect that:
<f:translate arguments="{0: '{username}'}">Hello {0}</f:translate>
shall work and I can than use helpers in one place only etc.
Also our customer is extracting f:translate tags automatically to xliff files. And than they are translating it like:
<source>Hello {username}</source>
<target>Czesc {username}</target>
And in this case the variable replacing is not working anymore. And than the arguments array makes no sense. And it is hard to explain to customer / translator to replace {whatever} to {0} and {1} and {2}... in proper order only in xliff files.
#9 Updated by Karsten Dambekalns about 3 years ago
- Status changed from Needs Feedback to Accepted
Krzysztof Daniel wrote:
Also our customer is extracting f:translate tags automatically to xliff files. And than they are translating it like:
Your provide the tool used and I'll fix this issue. Deal? ;)
#10 Updated by Gerrit Code Review about 3 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/12743
#11 Updated by Karsten Dambekalns about 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 96189df3951e77ed115c33d4a12603e0571c3f7a.
#12 Updated by Gerrit Code Review about 3 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch FLOW3-1.1 has been pushed to the review server.
It is available at http://review.typo3.org/12869
#13 Updated by Karsten Dambekalns about 3 years ago
- Status changed from Under Review to Resolved
- Target version changed from 1.1 to 1.1 RC2