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

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 #38

Open
Blakesalot opened this issue Sep 17, 2018 · 1 comment

Comments

@Blakesalot
Copy link

Blakesalot commented Sep 17, 2018

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:

  1. 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>
  1. Notice that they each have the same internationalized string "example string"
  2. Run ng xi18n && ngx-extractor -i /src/**/*.ts -f xlf -o .tmp/messages.xlf
  3. Take a look at the generated file: "messages.en-us.xlf"
  4. 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>
@Blakesalot Blakesalot changed the title Identical strings in .ts and .html results in no .ts source location reference in .xlf Same internationalized string appearing in both a .ts file and an .html file results in .xlf only specifying source location reference for the .html instance of the the string Sep 17, 2018
@Blakesalot Blakesalot changed the title Same internationalized string appearing in both a .ts file and an .html file results in .xlf only specifying source location reference for the .html instance of the the string 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 Sep 17, 2018
@JoniJnm
Copy link

JoniJnm commented Jan 23, 2019

Any progress with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants