i18n-polyfill
i18n-polyfill copied to clipboard
Same internationalized string appearing in both a .ts file and an .html file results in the generated .xlf only specifying source location for the .html instance of the the string
If the same internationalized string appears in both a .ts file and an .html file, the resulting .xlf only has a source location reference for the .html.
Repro steps:
- Insert the same internationalized string in both a .ts file and an .html file:
example.ts
import { Component } from "@angular/core";
import { I18n } from "@ngx-translate/i18n-polyfill";
@Component({
selector: "example",
templateUrl: "./example.html",
})
export class ExampleComponent {
exampleString = this.i18n("example string");
constructor(private i18n: I18n) {}
}
example.html
<div i18n>example string</div>
- Notice that they each have the same internationalized string "example string"
- Run
ng xi18n && ngx-extractor -i /src/**/*.ts -f xlf -o .tmp/messages.xlf
- Take a look at the generated file: "messages.en-us.xlf"
- Observe that only the html source file is listed as a location for the string.
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en-us" datatype="plaintext" original="ng2.template" target-language="en-us">
<body>
<trans-unit id="5fb0249db474cb03958ca04663b467e9646da391" datatype="html">
<source>example string</source>
<target state="final">example string</target>
<context-group purpose="location">
<context context-type="sourcefile">example.html</context>
<context context-type="linenumber">1</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>
Any progress with this?