Skip to content

Translate select and plural loses references in xliff, xliff2 and xmb files #17506

@CodeAndWeb

Description

@CodeAndWeb

I'm submitting a ...


[ ] Regression (behavior that used to work and stopped working in a new release)
[X] Bug report 
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Translate select and plural looses references in xliff, xliff2 and xmb files.

I have the following entries in my .html file:

<span i18n="@@span1">Here we have:
    {count, plural, =0 {zero} =1 {one}} or {gender, select, m {male} f {female}}
</span>

<span i18n="@@span2">Here we have:
    {gender, select, m {male} f {female}}
</span>

Note that span1 and span2 both use the same {gender, select, m {male} f {female}}. The result in xliff now is

  <trans-unit id="span1" datatype="html">
    <source>Here we have:
         <x id="ICU"/> or <x id="ICU_1"/>
    </source>
    <target/>
    <context-group purpose="location">
      <context context-type="sourcefile">app/dashboard-view/dashboard-view.component.ts</context>
      <context context-type="linenumber">28</context>
    </context-group>
  </trans-unit>
  <trans-unit id="847b0b589338e2d1ec3187b39d01510fce4fe9da" datatype="html">
    <source>{VAR_PLURAL, plural, =0 {zero} =1 {one} }</source>
    <target/>
    <context-group purpose="location">
      <context context-type="sourcefile">app/dashboard-view/dashboard-view.component.ts</context>
      <context context-type="linenumber">29</context>
    </context-group>
  </trans-unit>
  <trans-unit id="14c7055d67771a3b7b6888d282ac092896be06b6" datatype="html">
    <source>{VAR_SELECT, select, m {male} f {female} }</source>
    <target/>
    <context-group purpose="location">
      <context context-type="sourcefile">app/dashboard-view/dashboard-view.component.ts</context>
      <context context-type="linenumber">29</context>
    </context-group>
    <context-group purpose="location">
      <context context-type="sourcefile">app/dashboard-view/dashboard-view.component.ts</context>
      <context context-type="linenumber">34</context>
    </context-group>
  </trans-unit>
  <trans-unit id="span2" datatype="html">
    <source>Here we have:
         <x id="ICU"/>
    </source>
    <target/>
    <context-group purpose="location">
      <context context-type="sourcefile">app/dashboard-view/dashboard-view.component.ts</context>
      <context context-type="linenumber">33</context>
    </context-group>
  </trans-unit>

The problem is that the reference <x id="ICU"/> in span2 in the second block can't be found. It's not under this block.

From https://angular.io/guide/i18n:

The second translation unit, immediately below the first one, contains the select message. Translate that.

In this case: It's above because it was joined with the translation from span1 which you can see from the 2 context references in unit 14c7055d67771a3b7b6888d282ac092896be06b6

Expected behavior

Add a reference so that the matching translation unit can be found.

Minimal reproduction of the problem with instructions

See above.

What is the motivation / use case for changing the behavior?

Please tell us about your environment


Angular version:  4.2.1
For Tooling issues:
- Node version: 7
- Platform: Mac

Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: i18nIssues related to localization and internationalizationfeatureLabel used to distinguish feature request from other issuesfeature: in backlogFeature request for which voting has completed and is now in the backlogfeature: under considerationFeature request for which voting has completed and the request is now under considerationstate: has PR

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions