Project

General

Profile

Actions

Bug #31109

closed

XLIFF: Indent with new lines causes invalid output

Added by Xavier Perseguers over 12 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Must have
Category:
-
Target version:
Start date:
2011-10-19
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
4.6
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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).


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Task #31035: English XLIFF files should not contain target elementClosedXavier Perseguers2011-10-18

Actions
Related to TYPO3 Core - Bug #31141: Pootle: Multi-line labels are not rendered properlyClosedXavier Perseguers2011-10-20

Actions
Actions #1

Updated by Jigal van Hemert over 12 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.

Actions #2

Updated by Xavier Perseguers over 12 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.

Actions #3

Updated by Xavier Perseguers over 12 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
Actions #4

Updated by Xavier Perseguers over 12 years ago

Using PhpStorm with regular expression lookahead to remove tabs:

Search for: ^\t+(?![<\t])
Replace by:
For: *.xlf

Actions #5

Updated by Mr. Hudson over 12 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

Actions #6

Updated by Jigal van Hemert over 12 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).

Actions #7

Updated by Xavier Perseguers over 12 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 10 to 100
Actions #8

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF