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

ng xi18n - produces a new trans-unit when ICU message is divided into lines #6941

Closed
KrystianRos opened this issue Jul 11, 2017 · 2 comments
Closed
Assignees

Comments

@KrystianRos
Copy link

KrystianRos commented Jul 11, 2017

Bug Report or Feature Request (mark with an x)

- [x] bug report
- [ ] feature request

Versions.

@angular/cli: 1.1.2
node: 6.10.3
os: win32 x64
@angular/common: 4.2.2
@angular/compiler: 4.2.2
@angular/core: 4.2.2
@angular/forms: 4.2.2
@angular/http: 4.2.2
@angular/platform-browser: 4.2.2
@angular/platform-browser-dynamic: 4.2.2
@angular/router: 4.2.2
@angular/cli: 1.1.2
@angular/compiler-cli: 4.2.2

Repro steps.

Use ng xi18n --output-path src/i18n
when in html in project I have some ICU message which is not in the same line as beginning and ending
tag:

                        <span
				i18n="xyz|xyz@@SomeId">
				{text, select, question {Some text: {{someVar}}} error {Something went wrong..}}
			</span>

I become such output:

<trans-unit id="SomeId" datatype="html">
        <source>
				<x id="ICU"/>
			</source>
        <target/>
        <context-group purpose="location">
          <context context-type="sourcefile">secret</context>
          <context context-type="linenumber">secret</context>
        </context-group>
        <note priority="1" from="description">secret</note>
        <note priority="1" from="meaning">secret</note>
      </trans-unit>
      <trans-unit id="0f3d16437a38b6499cf229804051aca9d7b2774e" datatype="html">
        <source>{VAR_SELECT, select, question {Some text: {{someVar}}} error {Something went wrong..}}
</source>
        <target/>
        <context-group purpose="location">
          <context context-type="sourcefile">secret</context>
          <context context-type="linenumber">20</context>
        </context-group>
      </trans-unit>

Desired functionality.

It should produce only one translation unit- no matter if that is divided in more lines or not,

Mention any other details that might be useful.

Changing indents to tabs/spaces does not help.

@ocombe
Copy link
Contributor

ocombe commented Jul 18, 2017

Hello, spaces are considered as translation material, just like text. You might want to add or remove spaces in different translations, depending on the context and the language. ICU expressions are always extracted from translations into a different trans-unit and replaced by a placeholder <x id="ICU"/> in their original context.
If you don't want two trans-unit in this case, your html should not contain spaces before/after the ICU expression:

                        <span
				i18n="xyz|xyz@@SomeId">{text, select, question {Some text: {{someVar}}} error {Something went wrong..}}</span>

If you need those spaces/line feeds for some reason, you can use i18n comments instead of the i18n attribute:

                        <span>
				<!-- i18n:xyz|xyz@@SomeId -->{text, select, question {Some text: {{someVar}}} error {Something went wrong..}}<!-- /i18n -->
			</span>

@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 Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants