'ng extract-i18n configuration to ignore duplicate messages
In Angular v10, we are using the in-built i18n feature. Now when I run the ng extract-i18n it returns many duplicate message warnings.
Just a short example:
WARNINGS:
- Duplicate messages with id "lastName":
- "Last Name" : src\app\core...\
- "Last Name" ...
However, this is intentional on my part. I'm trying to REUSE certain i18n IDs throughout the application.
i.e. Some HTML snippets from various templates:
<label i18n="Label|Label for Last Name@@lastName">Last Name</label>
<mat-label i18n="Label|Label for Last Name@@lastName">Last Name</mat-label>
<mat-radio-button value="LastName" i18n="Button|Button for User Preferences@@lastName">
Last Name</mat-radio-button
>
<kendo-grid-column
i18n-title="Title|Title for Orders Grid@@firstName"
field="Student.FirstName"
title="First Name"
></kendo-grid-column>
In other words, text labels like "Last Name" and "First Name" are repeated a number of times in our application, so I have one generic i18n tag for each.
The CLI then generates the id attrib in the XLF output file:
<trans-unit id="lastName" datatype="html">
<source>Last Name</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/core/modals/.../info-modal.html</context>
<context context-type="linenumber">33</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/.../student-list.component.html</context>
<context context-type="linenumber">26</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/.../another-list.component.html</context>
<context context-type="linenumber">101</context>
</context-group>
</trans-unit>
Is there something wrong in this approach? Or is the Angular CLI just trying to be helpful?
I might be able to IGNORE those warnings, but it's not clear how.
I also found some info on github but it's not all too clear. https://github.com/angular/angular-cli/issues/19207
I also found a comment pointing to some config options: https://github.com/angular/angular/blob/79620f5139c80f1b3b38168744ca99a224c7e5cd/packages/localize/src/tools/src/extract/main.ts#L89-L95
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
