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

Space preservation attribute not added to XLF file #38679

Closed
ArtemAvramenko opened this issue Sep 2, 2020 · 7 comments
Closed

Space preservation attribute not added to XLF file #38679

ArtemAvramenko opened this issue Sep 2, 2020 · 7 comments

Comments

@ArtemAvramenko
Copy link

ArtemAvramenko commented Sep 2, 2020

🐞 bug report

Affected Package

The issue is caused by package @angular/localize^10.1.0-rc.0

Description

In ts code I use i18n:

title = $localize`hello\nworld` // tooltip should be shown in two lines

Then I call localize-extract and get xlf file without xml:space="preserve" attribute:

  ...
  <file source-language="en" datatype="plaintext" original="ng2.template">
  ...
      <trans-unit id="1122334455667788990" datatype="html">
        <source>Hello
world</source>
  ...

When I add translation in CAT tool (OmegaT), line break is gone.

🌍 Your Environment

Angular Version:

10.1.0-rc.0
@ngbot ngbot bot added this to the needsTriage milestone Sep 2, 2020
@petebacondarwin
Copy link
Member

I guess this would be a sensible attribute to include... let me just check it won't cause any problems.

petebacondarwin added a commit to petebacondarwin/angular that referenced this issue Sep 7, 2020
Whitespace can be relevant in extracted XLIFF translation files
and some i18n tools - e.g. CAT tool (OmegaT) - will reformat
the file to collapse whitespace if the is no indication to tell it
not to.

This commit adds the `xml:space="preserve"` attribute to the
rendered `<source>` element to indicate that the whitespace in
the source messages should be kept.

Fixes angular#38679
petebacondarwin added a commit to petebacondarwin/angular that referenced this issue Sep 7, 2020
Whitespace can be relevant in extracted XLIFF translation files
and some i18n tools - e.g. CAT tool (OmegaT) - will reformat
the file to collapse whitespace if the is no indication to tell it
not to.

This commit adds the `xml:space="preserve"` attribute to the
rendered `<source>` element to indicate that the whitespace in
the source messages should be kept.

Fixes angular#38679
@petebacondarwin
Copy link
Member

@ArtemAvramenko - did you consider trying to set the configuration of OmegaT? I see that there is a whitespace handling configuration in the "7.6 File Filters" section - https://omegat.sourceforge.io/manual-standard/en/windows.and.dialogs.html#dialogs.preferences.

@ArtemAvramenko
Copy link
Author

That are my options:
image

These options have effect on output, but the problem that OmegaT respects xml:space attribute, so it ignores whitespaces in source file.

@ArtemAvramenko
Copy link
Author

For now I run powershell script after resource extracting:

$file = Resolve-Path $args[0]
$content = [System.IO.File]::ReadAllText($file)
$content = $content -replace '(<file.+)>', '$1 xml:space="preserve">'
[System.IO.File]::WriteAllText($file, $content)

@ArtemAvramenko
Copy link
Author

Adding --preserveSpaces to localize-extract would be an ideal solution for me.

@petebacondarwin
Copy link
Member

Yeah, I think it might need to be behind a flag, since I am concerned that many XLIFF readers might not handle the xml namespaced attribute. It looks like XLIFF is trying to agree a specification for this but it has not made it standard yet.

petebacondarwin added a commit to petebacondarwin/angular that referenced this issue Sep 8, 2020
Whitespace can be relevant in extracted XLIFF translation files.
Some i18n tools - e.g. CAT tool (OmegaT) - will reformat
the file to collapse whitespace if there is no indication to tell it
not to.

This commit adds the ability to specify "format options" that are passed
to the translation file serializer. The XLIFF 1.2 and 2.0 seralizers have
been updated to accept `{"xml:space":"preserve"}` format option which will
by added to the `<file>` element in the serialized translation file during
extraction.

Fixes angular#38679
petebacondarwin added a commit to petebacondarwin/angular that referenced this issue Sep 8, 2020
Whitespace can be relevant in extracted XLIFF translation files.
Some i18n tools - e.g. CAT tool (OmegaT) - will reformat
the file to collapse whitespace if there is no indication to tell it
not to.

This commit adds the ability to specify "format options" that are passed
to the translation file serializer. The XLIFF 1.2 and 2.0 seralizers have
been updated to accept `{"xml:space":"preserve"}` format option which will
by added to the `<file>` element in the serialized translation file during
extraction.

Fixes angular#38679
petebacondarwin added a commit to petebacondarwin/angular that referenced this issue Sep 8, 2020
Whitespace can be relevant in extracted XLIFF translation files.
Some i18n tools - e.g. CAT tool (OmegaT) - will reformat
the file to collapse whitespace if there is no indication to tell it
not to.

This commit adds the ability to specify "format options" that are passed
to the translation file serializer. The XLIFF 1.2 and 2.0 seralizers have
been updated to accept `{"xml:space":"preserve"}` format option which will
by added to the `<file>` element in the serialized translation file during
extraction.

Fixes angular#38679
petebacondarwin added a commit to petebacondarwin/angular that referenced this issue Sep 8, 2020
Whitespace can be relevant in extracted XLIFF translation files.
Some i18n tools - e.g. CAT tool (OmegaT) - will reformat
the file to collapse whitespace if there is no indication to tell it
not to.

This commit adds the ability to specify "format options" that are passed
to the translation file serializer. The XLIFF 1.2 and 2.0 seralizers have
been updated to accept `{"xml:space":"preserve"}` format option which will
by added to the `<file>` element in the serialized translation file during
extraction.

Fixes angular#38679
petebacondarwin added a commit to petebacondarwin/angular that referenced this issue Sep 8, 2020
Whitespace can be relevant in extracted XLIFF translation files.
Some i18n tools - e.g. CAT tool (OmegaT) - will reformat
the file to collapse whitespace if there is no indication to tell it
not to.

This commit adds the ability to specify "format options" that are passed
to the translation file serializer. The XLIFF 1.2 and 2.0 seralizers have
been updated to accept `{"xml:space":"preserve"}` format option which will
by added to the `<file>` element in the serialized translation file during
extraction.

Fixes angular#38679
@atscott atscott closed this as completed in 4360eed Sep 8, 2020
atscott pushed a commit that referenced this issue Sep 8, 2020
…38737)

Whitespace can be relevant in extracted XLIFF translation files.
Some i18n tools - e.g. CAT tool (OmegaT) - will reformat
the file to collapse whitespace if there is no indication to tell it
not to.

This commit adds the ability to specify "format options" that are passed
to the translation file serializer. The XLIFF 1.2 and 2.0 seralizers have
been updated to accept `{"xml:space":"preserve"}` format option which will
by added to the `<file>` element in the serialized translation file during
extraction.

Fixes #38679

PR Close #38737
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants