Bug #31109
closedXLIFF: Indent with new lines causes invalid output
100%
Description
Recently #31035 added indent to labels with embedded new lines (using command-line tool xmlindent). This causes wrong output when the label is used in a non-HTML context (e.g., as email template).
Moreover, it seems that translations (German for instance) suffer the same problem. This should be analyzed to understand where the indent comes from (plain XML output from Pootle or from some post-processing while preparing the localization packages for TER).
Updated by Jigal van Hemert over 13 years ago
Examples for problematic labels:
typo3/sysext/felogin/pi1/locallang.xlf
<trans-unit id="ll_forgot_email_password"> <source>Your password Hi %s Your username is "%s" Your password is "%s" </source> </trans-unit> <trans-unit id="ll_forgot_email_nopassword"> <source>Your password Hi %s We couldn't find a username for this email address and so cannot send the password to you. Probably you misspelled the email address (upper/lower case makes a difference) or maybe you even didn't register yet? </source> </trans-unit> <trans-unit id="ll_forgot_validate_reset_password"> <source>Your new password Dear %s, This email was sent in response to your request to reset your password. Please click on the link below. %s For security reasons, this link is only active until %s. If you do not visit the link before then, you will need to repeat the password reset steps. </source> </trans-unit>
The first line is in these cases used as subject for the email and all other lines are the body of the mail. Because it's plain text email they should not have whitespace prepended.
Updated by Xavier Perseguers over 13 years ago
- Assignee set to Xavier Perseguers
- % Done changed from 0 to 10
OK, so the point is:
- XLIFF files are missing a pretty tiny attribute best to be set on the <file> tag: xml:space="preserve" which helps Pootle keeping line breaks without thinking it would be wise removing them
- Yesterday we refactored XLIFF files to remove the target attribute, at the end of the process we used the tool "xmlindent" to reindent the XML. This has the side effect that text on multiple lines get each line indented by tabs. Those tabs are then taken as-this by TYPO3 L10n and gives wrong output when label is used in some preformatted environment. We can easily "revert that" but we still have to face the possibility that users will use offline tool for translating TYPO3 and those tools are very likely to reindent the XML in their back.
Solution: ask TYPO3 to "trim" tabs at the beginning of each line. It does not make sense to have tabs there, if alignment is done in preformatted environment (email messages for instance), aligning by spaces is the way to go anyway
We will come up with a few patches to fix that. In addition extdeveval should ideally generate XLIFF files with this flag already set.
Updated by Xavier Perseguers over 13 years ago
Thinking more about this issue:
- We cannot remove tabs at the beginning within TYPO3 or we should either fix it in ll-XML generated files while packaging or we have to update all versions of TYPO3 (not doable)
- If we fix the output in ll-XML while packaging, why not fix it as well for XLIFF files? If Pootle happens to output translated XLF with indent of course, which might not be the case with xml:space="preserve"
- It's easy to fix the source files (in Core) so do it anyway otherwise the labels will contain \t all over the lines in Pootle
Updated by Xavier Perseguers over 13 years ago
Using PhpStorm with regular expression lookahead to remove tabs:
Search for: ^\t+(?![<\t])
Replace by:
For: *.xlf
Updated by Mr. Hudson over 13 years ago
- Status changed from New to Under Review
Patch set 1 of change I31850fdff437b81f5b07a2e58ac2281d10a8d1c4 has been pushed to the review server.
It is available at http://review.typo3.org/6062
Updated by Jigal van Hemert over 13 years ago
Solution for English xliff files is great (already voted in Gerrit). Is there anything we can do for translations in Pootle? Can the affected labels be detected in Pootle? Then we can notify the translators to check and fix the translations (e.g. because they have been translated or changed recently and now have whitespace removed).
Updated by Xavier Perseguers over 13 years ago
- Status changed from Under Review to Resolved
- % Done changed from 10 to 100
Applied in changeset b4ee04f4d0d0f0242e395acf0d80b88db50349da.
Updated by Riccardo De Contardi over 7 years ago
- Status changed from Resolved to Closed