Skip to content

Instantly share code, notes, and snippets.

@bettysteger
Last active October 20, 2016 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bettysteger/a0cc19c2296a98f93e48f1bfb5ddb676 to your computer and use it in GitHub Desktop.
Save bettysteger/a0cc19c2296a98f93e48f1bfb5ddb676 to your computer and use it in GitHub Desktop.
ng-xi18n: Extracts texts and creates a XLIFF file in Angular 2, ready for translation
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<h1 i18n>Hello world</h1>
<p i18n="example description">This is an {{details}} paragraph</p>
<p>should not be translated</p>
<p i18n>I ❤ LingoHub</p>
`
})
export class AppComponent {
details = 'example';
}
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="c8793269a943c10686b41f4f4f890875016783fc" datatype="html">
<source>Hello world</source>
<target/>
</trans-unit>
<trans-unit id="1ecda48b29cdbe90ec39cf2fc0e93c87819a563d" datatype="html">
<source>This is an <x id="INTERPOLATION"/> paragraph</source>
<target/>
<note priority="1" from="description">example description</note>
</trans-unit>
<trans-unit id="dfac9682a27fa25dcb19affd925d2b341798bf12" datatype="html">
<source>I ❤ LingoHub</source>
<target/>
</trans-unit>
</body>
</file>
</xliff>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment