Skip to content

extract-i18n: Extract description for every instance of duplicated messages #49564

@antimagnes

Description

@antimagnes

Command

extract-i18n

Description

ng extract-i18n only considers the description of the first occurrence of a duplicated message.

The relevant code part I found is this, which tells me, that for description the first element of the duplicatedMessages array is used, whichever it may be.

for (const duplicateMessages of messageGroups) {
const message = duplicateMessages[0];
const id = this.getMessageId(message);
xml.startTag('trans-unit', {id, datatype: 'html'});
xml.startTag('source', {}, {preserveWhitespace: true});
this.serializeMessage(xml, message);
xml.endTag('source', {preserveWhitespace: false});
// Write all the locations
for (const {location} of duplicateMessages.filter(hasLocation)) {
this.serializeLocation(xml, location);
}
if (message.description) {
this.serializeNote(xml, 'description', message.description);
}
if (message.meaning) {
this.serializeNote(xml, 'meaning', message.meaning);
}
xml.endTag('trans-unit');
}
xml.endTag('body');
xml.endTag('file');
xml.endTag('xliff');
return xml.toString();
}

E.g.: there are three different components that use the same text to display a label "Owner" that should be localised.

detail.component.html
...
 <ng-container id="ownerLabel" i18n="Owner label in detail form">Owner</ng-container>
...
search.component.html
...
 <ng-container id="ownerLabel" i18n="Owner label in search filter">Owner</ng-container>
...
search-result-table.component.ts
...
  displayText: $localize`:Owner table column header in search result table:Owner`,
...

For this following trans-unit is generated

<trans-unit id="3016960930275947563" datatype="html">
  <source>Owner</source>
  <context-group purpose="location">
    <context context-type="sourcefile">src/app/detail/detail.component.html</context>
    <context context-type="linenumber">81</context>
  </context-group>
  <context-group purpose="location">
    <context context-type="sourcefile">src/app/search/search.component.html</context>
    <context context-type="linenumber">54</context>
  </context-group>
  <context-group purpose="location">
    <context context-type="sourcefile">src/app/detail/search-result-table.component.ts</context>
    <context context-type="linenumber">111</context>
  </context-group>
  <note priority="1" from="description">Owner label in detail form</note>
</trans-unit>

Describe the solution you'd like

Motivation:

We have a use-case where we send UI texts to be translated to some tech-savvy business colleagues who know the application and needs to translate missing texts. To those users the different descriptions matter, since it is a clear overview which parts of the application are meant and sometimes certain labels in different positions need to have different translations. In our communication to be able to identify which label we are talking about this description would be really helpful.

Proposed solution:

Add an extra parameter to ng extract-18n that would also generate the <context context-type="description"> tags for duplicated messages.

According to http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#context I do not see any problem with adding one more XML tag to the <context-group purpose="location">s, e.g.

<trans-unit id="3016960930275947563" datatype="html">
  <source>Owner</source>
  <context-group purpose="location">
    <context context-type="sourcefile">src/app/detail/detail.component.html</context>
    <context context-type="linenumber">81</context>
    <context context-type="description">Owner label in detail form</context>
  </context-group>
  <context-group purpose="location">
    <context context-type="sourcefile">src/app/search/search.component.html</context>
    <context context-type="linenumber">54</context>
    <context context-type="description">Owner label in search filter</context>
  </context-group>
  <context-group purpose="location">
    <context context-type="sourcefile">src/app/detail/search-result-table.component.ts</context>
    <context context-type="linenumber">111</context>
    <context context-type="description">Owner table column header in search result table</context>
  </context-group>
  <note priority="1" from="description">Owner label in detail form</note>
</trans-unit>

Describe alternatives you've considered

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: i18nIssues related to localization and internationalization

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy