docs(aio): updated i18n guide and example (#19975)
This commit is contained in:
parent
3db7112b89
commit
132c0719dc
|
@ -29,4 +29,3 @@
|
|||
<!--#docregion i18n-title-->
|
||||
<img [src]="logo" title="Angular logo">
|
||||
<!--#enddocregion i18n-title-->
|
||||
Contact GitHub API Training Shop Blog About
|
|
@ -0,0 +1,7 @@
|
|||
// #docregion import-locale-extra
|
||||
import { registerLocaleData } from '@angular/common';
|
||||
import localeFrCa from '@angular/common/locales/fr-CA';
|
||||
import localeFrCaExtra from '@angular/common/locales/extra/fr-CA';
|
||||
|
||||
registerLocaleData(localeFrCa, localeFrCaExtra);
|
||||
// #enddocregion import-locale-extra
|
|
@ -0,0 +1,13 @@
|
|||
// #docregion
|
||||
import { LOCALE_ID, NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { AppComponent } from '../src/app/app.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [ BrowserModule ],
|
||||
declarations: [ AppComponent ],
|
||||
providers: [ { provide: LOCALE_ID, useValue: 'fr' } ],
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
export class AppModule { }
|
|
@ -1,6 +1,12 @@
|
|||
// #docregion
|
||||
import { enableProdMode } from '@angular/core';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app/app.module';
|
||||
import { environment } from './environments/environment';
|
||||
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
|
@ -0,0 +1,22 @@
|
|||
// #docregion
|
||||
import { enableProdMode, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app/app.module';
|
||||
import { environment } from './environments/environment';
|
||||
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
// use the require method provided by webpack
|
||||
declare const require;
|
||||
// we use the webpack raw-loader to return the content as a string
|
||||
const translations = require(`raw-loader!./locale/messages.fr.xlf`);
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule, {
|
||||
providers: [
|
||||
{provide: TRANSLATIONS, useValue: translations},
|
||||
{provide: TRANSLATIONS_FORMAT, useValue: 'xlf'}
|
||||
]
|
||||
});
|
|
@ -0,0 +1,13 @@
|
|||
// #docregion
|
||||
import { MissingTranslationStrategy } from '@angular/core';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { AppModule } from './app/app.module';
|
||||
|
||||
// ...
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule, {
|
||||
missingTranslation: MissingTranslationStrategy.Error,
|
||||
providers: [
|
||||
// ...
|
||||
]
|
||||
});
|
|
@ -0,0 +1,73 @@
|
|||
<!-- The `messages.fr.xlf` after translation for documentation purposes -->
|
||||
<!-- #docregion -->
|
||||
<?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>
|
||||
<!-- #docregion translated-hello-before -->
|
||||
<trans-unit id="introductionHeader" datatype="html">
|
||||
<source>Hello i18n!</source>
|
||||
<note priority="1" from="description">An introduction header for this sample</note>
|
||||
<note priority="1" from="meaning">User welcome</note>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translated-hello-before -->
|
||||
<!-- #docregion translated-hello -->
|
||||
<!-- #docregion custom-id -->
|
||||
<trans-unit id="introductionHeader" datatype="html">
|
||||
<!-- #enddocregion custom-id -->
|
||||
<source>Hello i18n!</source>
|
||||
<target>Bonjour i18n !</target>
|
||||
<note priority="1" from="description">An introduction header for this sample</note>
|
||||
<note priority="1" from="meaning">User welcome</note>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translated-hello -->
|
||||
<!-- #docregion translated-other-nodes -->
|
||||
<!-- #docregion generated-id -->
|
||||
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
|
||||
<!-- #enddocregion generated-id -->
|
||||
<source>I don't output any element</source>
|
||||
<target>Je n'affiche aucun élément</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
|
||||
<source>Angular logo</source>
|
||||
<target>Logo d'Angular</target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translated-other-nodes -->
|
||||
<!-- #docregion translated-plural -->
|
||||
<trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
|
||||
<source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
|
||||
<target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translated-plural -->
|
||||
<!-- #docregion translated-select -->
|
||||
<!-- #docregion translate-select-1 -->
|
||||
<trans-unit id="52515023fc70c216ef291086c1962ff135a9fe13" datatype="html">
|
||||
<source>The author is <x id="ICU" equiv-text="{gender, select, m {...} f {...} o {...}}"/></source>
|
||||
<target>L'auteur est <x id="ICU" equiv-text="{gender, select, m {...} f {...} o {...}}"/></target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translate-select-1 -->
|
||||
<!-- #docregion translate-select-2 -->
|
||||
<trans-unit id="4e6fd3f2bb3477e8ad2088f03257f6e1b8b515a5" datatype="html">
|
||||
<source>{VAR_SELECT, select, m {male} f {female} o {other} }</source>
|
||||
<target>{VAR_SELECT, select, m {un homme} f {une femme} o {autre} }</target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translate-select-2 -->
|
||||
<!-- #enddocregion translated-select -->
|
||||
<!-- #docregion translate-nested -->
|
||||
<!-- #docregion translate-nested-1 -->
|
||||
<trans-unit id="f7a55c9ef7c5b37147825a9041263305063e63e9" datatype="html">
|
||||
<source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
|
||||
<target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translate-nested-1 -->
|
||||
<!-- #docregion translate-nested-2 -->
|
||||
<trans-unit id="80b5ac44661751e191225c0b1e000bceeeccb52c" datatype="html">
|
||||
<source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, m {male} f {female} o {other} }} }</source>
|
||||
<target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, m {un homme} f {une femme} o {autre} }} }</target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translate-nested-2 -->
|
||||
<!-- #enddocregion translate-nested -->
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
'use strict'; // necessary for es6 output in node
|
||||
|
||||
import { browser, element, by } from 'protractor';
|
||||
|
||||
describe('i18n E2E Tests', () => {
|
||||
|
||||
beforeEach(function () {
|
||||
browser.get('');
|
||||
});
|
||||
|
||||
it('should display i18n translated welcome: ¡Hola i18n!', function () {
|
||||
expect(element(by.css('h1')).getText()).toEqual('¡Hola i18n!');
|
||||
});
|
||||
|
||||
it('should display the node texts without elements', function () {
|
||||
expect(element(by.css('my-app')).getText()).toContain('No genero ningún elemento');
|
||||
});
|
||||
|
||||
it('should display the translated title attribute', function () {
|
||||
const title = element(by.css('img')).getAttribute('title');
|
||||
expect(title).toBe('Logo de Angular');
|
||||
});
|
||||
|
||||
it('should display the plural of: a horde of wolves', function () {
|
||||
expect(element.all(by.css('span')).get(0).getText()).toBe('ningún lobo');
|
||||
});
|
||||
|
||||
it('should display the select of gender', function () {
|
||||
expect(element.all(by.css('span')).get(1).getText()).toBe('El heroe es mujer');
|
||||
});
|
||||
|
||||
it('should display the nested expression', function() {
|
||||
expect(element.all(by.css('span')).get(2).getText()).toBe('Aquí tenemos: 3 mujeres');
|
||||
});
|
||||
|
||||
});
|
|
@ -0,0 +1,45 @@
|
|||
import { browser, element, by } from 'protractor';
|
||||
|
||||
describe('i18n E2E Tests', () => {
|
||||
|
||||
beforeEach(function () {
|
||||
browser.get('');
|
||||
});
|
||||
|
||||
it('should display i18n translated welcome: Bonjour !', function () {
|
||||
expect(element(by.css('h1')).getText()).toEqual('Bonjour i18n !');
|
||||
});
|
||||
|
||||
it('should display the node texts without elements', function () {
|
||||
expect(element(by.css('app-root')).getText()).toContain(`Je n'affiche aucun élément`);
|
||||
});
|
||||
|
||||
it('should display the translated title attribute', function () {
|
||||
const title = element(by.css('img')).getAttribute('title');
|
||||
expect(title).toBe(`Logo d'Angular`);
|
||||
});
|
||||
|
||||
it('should display the ICU plural expression', function () {
|
||||
expect(element.all(by.css('span')).get(0).getText()).toBe(`Mis à jour à l'instant`);
|
||||
});
|
||||
|
||||
it('should display the ICU select expression', function () {
|
||||
const selectIcuExp = element.all(by.css('span')).get(1);
|
||||
expect(selectIcuExp.getText()).toBe(`L'auteur est une femme`);
|
||||
element.all(by.css('button')).get(2).click();
|
||||
expect(selectIcuExp.getText()).toBe(`L'auteur est un homme`);
|
||||
});
|
||||
|
||||
it('should display the nested expression', function() {
|
||||
const nestedExp = element.all(by.css('span')).get(2);
|
||||
const incBtn = element.all(by.css('button')).get(0);
|
||||
expect(nestedExp.getText()).toBe(`Mis à jour: à l'instant`);
|
||||
incBtn.click();
|
||||
expect(nestedExp.getText()).toBe(`Mis à jour: il y a une minute`);
|
||||
incBtn.click();
|
||||
incBtn.click();
|
||||
element.all(by.css('button')).get(4).click();
|
||||
expect(nestedExp.getText()).toBe(`Mis à jour: il y a 3 minutes par autre`);
|
||||
});
|
||||
|
||||
});
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"projectType": "i18n"
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?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="introductionHeader" datatype="html">
|
||||
<source>
|
||||
Hello i18n!
|
||||
</source>
|
||||
<target/>
|
||||
<note priority="1" from="description">An introduction header for this sample</note>
|
||||
<note priority="1" from="meaning">User welcome</note>
|
||||
</trans-unit>
|
||||
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
|
||||
<source>I don't output any element</source>
|
||||
<target/>
|
||||
</trans-unit>
|
||||
<trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
|
||||
<source>Angular logo</source>
|
||||
<target/>
|
||||
</trans-unit>
|
||||
<trans-unit id="6e22e74e8cbd3095560cfe08993c4fdfa3c50eb0" datatype="html">
|
||||
<source/>
|
||||
<target/>
|
||||
</trans-unit>
|
||||
<trans-unit id="61cafedb85466ab789b3ae817bba1a545468ee1c" datatype="html">
|
||||
<source>The hero is <x id="ICU"/></source>
|
||||
<target/>
|
||||
</trans-unit>
|
||||
<trans-unit id="14c7055d67771a3b7b6888d282ac092896be06b6" datatype="html">
|
||||
<source/>
|
||||
<target/>
|
||||
</trans-unit>
|
||||
<trans-unit id="2cf9a08c5b6e3612572a2a36dd46563013848382" datatype="html">
|
||||
<source>Here we have: <x id="ICU"/></source>
|
||||
<target/>
|
||||
</trans-unit>
|
||||
<trans-unit id="db1b921b55301ce3957e382090729562002da036" datatype="html">
|
||||
<source/>
|
||||
<target/>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"description": "i18n",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"app/**/*.css",
|
||||
"app/**/*.html",
|
||||
"app/**/*.ts",
|
||||
"messages.xlf",
|
||||
"locale/messages.*.xlf",
|
||||
|
||||
"!**/*.[1].*",
|
||||
|
||||
"main.ts",
|
||||
"styles.css",
|
||||
"systemjs-text-plugin.js",
|
||||
"index.html"
|
||||
],
|
||||
"tags": ["i18n"]
|
||||
}
|
|
@ -17,19 +17,19 @@
|
|||
<br>
|
||||
<button (click)="inc(1)">+</button> <button (click)="inc(-1)">-</button>
|
||||
<!--#docregion i18n-plural-->
|
||||
<span i18n>{wolves, plural, =0 {no wolves} =1 {one wolf} =2 {two wolves} other {a wolf pack}}</span>
|
||||
<span i18n>Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}}</span>
|
||||
<!--#enddocregion i18n-plural-->
|
||||
({{wolves}})
|
||||
({{minutes}})
|
||||
<br><br>
|
||||
<button (click)="male()">♂</button> <button (click)="female()">♀</button>
|
||||
<button (click)="male()">♂</button> <button (click)="female()">♀</button> <button (click)="other()">⚧</button>
|
||||
<!--#docregion i18n-select-->
|
||||
<span i18n>The hero is {gender, select, m {male} f {female}}</span>
|
||||
<span i18n>The author is {gender, select, m {male} f {female} o {other}}</span>
|
||||
<!--#enddocregion i18n-select-->
|
||||
<br><br>
|
||||
<!--#docregion i18n-nested-->
|
||||
<span i18n>Here we have: {count, plural,
|
||||
=0 {no one}
|
||||
=1 {one {gender, select, male {man} female {woman}}}
|
||||
other {{{heroes.length}} {gender, select, male {men} female {women}}}
|
||||
}</span>
|
||||
<span i18n>Updated: {minutes, plural,
|
||||
=0 {just now}
|
||||
=1 {one minute ago}
|
||||
other {{{minutes}} minutes ago by {gender, select, m {male} f {female} o {other}}}}
|
||||
</span>
|
||||
<!--#enddocregion i18n-nested-->
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html'
|
||||
})
|
||||
export class AppComponent {
|
||||
wolves = 0;
|
||||
minutes = 0;
|
||||
gender = 'f';
|
||||
fly = true;
|
||||
logo = 'https://angular.io/assets/images/logos/angular/angular.png';
|
||||
count = 3;
|
||||
heroes: string[] = ['Magneta', 'Celeritas', 'Dynama'];
|
||||
inc(i: number) {
|
||||
this.wolves = Math.min(5, Math.max(0, this.wolves + i));
|
||||
this.minutes = Math.min(5, Math.max(0, this.minutes + i));
|
||||
}
|
||||
male() { this.gender = 'm'; }
|
||||
male() { this.gender = 'm'; }
|
||||
female() { this.gender = 'f'; }
|
||||
other() { this.gender = 'o'; }
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
// #docregion import-locale-extra
|
||||
import { registerLocaleData } from '@angular/common';
|
||||
import localeEnGB from '@angular/common/locales/en-GB';
|
||||
import localeEnGBExtra from '@angular/common/locales/extra/en-GB';
|
||||
|
||||
registerLocaleData(localeEnGB, localeEnGBExtra);
|
||||
// #enddocregion import-locale-extra
|
|
@ -1,13 +1,12 @@
|
|||
// #docregion
|
||||
import { NgModule } from '@angular/core';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [ BrowserModule ],
|
||||
imports: [ BrowserModule ],
|
||||
declarations: [ AppComponent ],
|
||||
bootstrap: [ AppComponent ]
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
|
||||
export class AppModule { }
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
// #docplaster
|
||||
// #docregion without-missing-translation
|
||||
import { TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID, MissingTranslationStrategy, StaticProvider } from '@angular/core';
|
||||
import { CompilerConfig } from '@angular/compiler';
|
||||
|
||||
export function getTranslationProviders(): Promise<StaticProvider[]> {
|
||||
|
||||
// Get the locale id from the global
|
||||
const locale = document['locale'] as string;
|
||||
|
||||
// return no providers if fail to get translation file for locale
|
||||
const noProviders: StaticProvider[] = [];
|
||||
|
||||
// No locale or U.S. English: no translation providers
|
||||
if (!locale || locale === 'en-US') {
|
||||
return Promise.resolve(noProviders);
|
||||
}
|
||||
|
||||
// Ex: 'locale/messages.es.xlf`
|
||||
const translationFile = `./locale/messages.${locale}.xlf`;
|
||||
|
||||
// #docregion missing-translation
|
||||
return getTranslationsWithSystemJs(translationFile)
|
||||
.then( (translations: string ) => [
|
||||
{ provide: TRANSLATIONS, useValue: translations },
|
||||
{ provide: TRANSLATIONS_FORMAT, useValue: 'xlf' },
|
||||
{ provide: LOCALE_ID, useValue: locale },
|
||||
// #enddocregion without-missing-translation
|
||||
{ provide: CompilerConfig, useValue: new CompilerConfig({ missingTranslation: MissingTranslationStrategy.Error }) }
|
||||
// #docregion without-missing-translation
|
||||
])
|
||||
.catch(() => noProviders); // ignore if file not found
|
||||
// #enddocregion missing-translation
|
||||
}
|
||||
|
||||
declare var System: any;
|
||||
|
||||
function getTranslationsWithSystemJs(file: string) {
|
||||
return System.import(file + '!text'); // relies on text plugin
|
||||
}
|
||||
// #enddocregion without-missing-translation
|
|
@ -1,39 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- #docregion -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Angular i18n example</title>
|
||||
<base href="/">
|
||||
<title>Angular i18n example</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
|
||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||
|
||||
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||
|
||||
<script src="systemjs.config.js"></script>
|
||||
|
||||
<!-- #docregion i18n -->
|
||||
<script>
|
||||
// Get the locale id somehow
|
||||
document.locale = 'es';
|
||||
|
||||
// Map to the text plugin
|
||||
System.config({
|
||||
map: {
|
||||
text: 'systemjs-text-plugin.js'
|
||||
}
|
||||
});
|
||||
|
||||
// Launch the app
|
||||
System.import('main.js').catch(function(err){ console.error(err); });
|
||||
</script>
|
||||
<!-- #enddocregion i18n -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<my-app>Loading...</my-app>
|
||||
<app-root>Loading...</app-root>
|
||||
</body>
|
||||
</html>
|
||||
<!-- #enddocregion -->
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
<?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="introductionHeader" datatype="html">
|
||||
<source>Hello i18n!</source>
|
||||
<target>¡Hola i18n!</target>
|
||||
<note priority="1" from="description">An introduction header for this sample</note>
|
||||
<note priority="1" from="meaning">User welcome</note>
|
||||
</trans-unit>
|
||||
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
|
||||
<source>I don't output any element</source>
|
||||
<target>No genero ningún elemento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
|
||||
<source>Angular logo</source>
|
||||
<target>Logo de Angular</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6e22e74e8cbd3095560cfe08993c4fdfa3c50eb0" datatype="html">
|
||||
<source/>
|
||||
<target>{wolves, plural, =0 {ningún lobo} =1 {un lobo} =2 {dos lobos} other {una horda de lobos}}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="61cafedb85466ab789b3ae817bba1a545468ee1c" datatype="html">
|
||||
<source>The hero is <x id="ICU"/></source>
|
||||
<target>El heroe es <x id="ICU"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="14c7055d67771a3b7b6888d282ac092896be06b6" datatype="html">
|
||||
<source/>
|
||||
<target>{gender, select, m {hombre} f {mujer}}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2cf9a08c5b6e3612572a2a36dd46563013848382" datatype="html">
|
||||
<source>Here we have: <x id="ICU"/></source>
|
||||
<target>Aquí tenemos: <x id="ICU"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="db1b921b55301ce3957e382090729562002da036" datatype="html">
|
||||
<source/>
|
||||
<target>
|
||||
{count, plural,
|
||||
=0 { nadie }
|
||||
=1 {{gender, select, m {un hombre} f {una mujer}}}
|
||||
other {{{heroes.length}} {gender, select, m {hombres} f {mujeres}}}
|
||||
}
|
||||
</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -1,80 +0,0 @@
|
|||
<!-- The `messages.es.xlf` after translation for documentation purposes -->
|
||||
<!-- #docregion -->
|
||||
<?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>
|
||||
<!-- #docregion translated-hello -->
|
||||
<!-- #docregion custom-id -->
|
||||
<trans-unit id="introductionHeader" datatype="html">
|
||||
<!-- #enddocregion custom-id -->
|
||||
<source>Hello i18n!</source>
|
||||
<target>¡Hola i18n!</target>
|
||||
<note priority="1" from="description">An introduction header for this sample</note>
|
||||
<note priority="1" from="meaning">User welcome</note>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translated-hello -->
|
||||
<!-- #docregion translated-other-nodes -->
|
||||
<!-- #docregion generated-id -->
|
||||
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
|
||||
<!-- #enddocregion generated-id -->
|
||||
<source>I don't output any element</source>
|
||||
<target>No genero ningún elemento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
|
||||
<source>Angular logo</source>
|
||||
<target>Logo de Angular</target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translated-other-nodes -->
|
||||
<!-- #docregion translated-plural -->
|
||||
<trans-unit id="6e22e74e8cbd3095560cfe08993c4fdfa3c50eb0" datatype="html">
|
||||
<source/>
|
||||
<target>{wolves, plural, =0 {ningún lobo} =1 {un lobo} =2 {dos lobos} other {una horda de lobos}}</target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translated-plural -->
|
||||
<!-- #docregion translated-select -->
|
||||
<!-- #docregion translate-select-1 -->
|
||||
<trans-unit id="61cafedb85466ab789b3ae817bba1a545468ee1c" datatype="html">
|
||||
<source>The hero is <x id="ICU"/></source>
|
||||
<target>El heroe es <x id="ICU"/></target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translate-select-1 -->
|
||||
<!-- #docregion translate-select-2 -->
|
||||
<trans-unit id="14c7055d67771a3b7b6888d282ac092896be06b6" datatype="html">
|
||||
<source/>
|
||||
<target>{gender, select, m {hombre} f {mujer}}</target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translate-select-2 -->
|
||||
<!-- #enddocregion translated-select -->
|
||||
<trans-unit id="db04527df562d12c8607eab2b5723ef6e2066ba0" datatype="html">
|
||||
<source>Here we have: <x id="ICU"/></source>
|
||||
<target/>
|
||||
</trans-unit>
|
||||
<trans-unit id="000058be4e6f08b685d1d0a70f9da68067df7379" datatype="html">
|
||||
<source/>
|
||||
<target/>
|
||||
</trans-unit>
|
||||
<!-- #docregion translate-nested -->
|
||||
<!-- #docregion translate-nested-1 -->
|
||||
<trans-unit id="2cf9a08c5b6e3612572a2a36dd46563013848382" datatype="html">
|
||||
<source>Here we have: <x id="ICU"/></source>
|
||||
<target>Aquí tenemos: <x id="ICU"/></target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translate-nested-1 -->
|
||||
<!-- #docregion translate-nested-2 -->
|
||||
<trans-unit id="db1b921b55301ce3957e382090729562002da036" datatype="html">
|
||||
<source/>
|
||||
<target>
|
||||
{count, plural,
|
||||
=0 { nadie }
|
||||
=1 {{gender, select, m {un hombre} f {una mujer}}}
|
||||
other {{{heroes.length}} {gender, select, m {hombres} f {mujeres}}}
|
||||
}
|
||||
</target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translate-nested-2 -->
|
||||
<!-- #enddocregion translate-nested -->
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<?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="introductionHeader" datatype="html">
|
||||
<source>
|
||||
Hello i18n!
|
||||
</source>
|
||||
<target>
|
||||
Bonjour i18n !
|
||||
</target>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">4</context>
|
||||
</context-group>
|
||||
<note priority="1" from="description">An introduction header for this sample</note>
|
||||
<note priority="1" from="meaning">User welcome</note>
|
||||
</trans-unit>
|
||||
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
|
||||
<source>I don't output any element</source>
|
||||
<target>Je n'affiche aucun élément</target>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">10</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
|
||||
<source>Angular logo</source>
|
||||
<target>Logo d'Angular</target>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">16</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="d69f6b42305f49332026fef24b40227f02e34594" datatype="html">
|
||||
<source>Updated <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
|
||||
<target>Mis à jour <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">21</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
|
||||
<source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
|
||||
<target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">21</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="52515023fc70c216ef291086c1962ff135a9fe13" datatype="html">
|
||||
<source>The author is <x id="ICU" equiv-text="{gender, select, m {...} f {...} o {...}}"/></source>
|
||||
<target>L'auteur est <x id="ICU" equiv-text="{gender, select, m {...} f {...} o {...}}"/></target>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">27</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="4e6fd3f2bb3477e8ad2088f03257f6e1b8b515a5" datatype="html">
|
||||
<source>{VAR_SELECT, select, m {male} f {female} o {other} }</source>
|
||||
<target>{VAR_SELECT, select, m {un homme} f {une femme} o {autre} }</target>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">27</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="f7a55c9ef7c5b37147825a9041263305063e63e9" datatype="html">
|
||||
<source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/>
|
||||
</source>
|
||||
<target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/>
|
||||
</target>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">31</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="80b5ac44661751e191225c0b1e000bceeeccb52c" datatype="html">
|
||||
<source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, m {male} f {female} o {other} }} }</source>
|
||||
<target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, m {un homme} f {une femme} o {autre} }} }</target>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">31</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -0,0 +1,75 @@
|
|||
<?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="introductionHeader" datatype="html">
|
||||
<source>
|
||||
Hello i18n!
|
||||
</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">4</context>
|
||||
</context-group>
|
||||
<note priority="1" from="description">An introduction header for this sample</note>
|
||||
<note priority="1" from="meaning">User welcome</note>
|
||||
</trans-unit>
|
||||
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
|
||||
<source>I don't output any element</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">10</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
|
||||
<source>Angular logo</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">16</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="d69f6b42305f49332026fef24b40227f02e34594" datatype="html">
|
||||
<source>Updated <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">21</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
|
||||
<source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">21</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="52515023fc70c216ef291086c1962ff135a9fe13" datatype="html">
|
||||
<source>The author is <x id="ICU" equiv-text="{gender, select, m {...} f {...} o {...}}"/></source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">27</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="4e6fd3f2bb3477e8ad2088f03257f6e1b8b515a5" datatype="html">
|
||||
<source>{VAR_SELECT, select, m {male} f {female} o {other} }</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">27</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="f7a55c9ef7c5b37147825a9041263305063e63e9" datatype="html">
|
||||
<source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/>
|
||||
</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">31</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="80b5ac44661751e191225c0b1e000bceeeccb52c" datatype="html">
|
||||
<source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, m {male} f {female} o {other} }} }</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">app\app.component.ts</context>
|
||||
<context context-type="linenumber">31</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
|
@ -1,10 +1,12 @@
|
|||
// #docregion
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { getTranslationProviders } from './app/i18n-providers';
|
||||
import { enableProdMode } from '@angular/core';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app/app.module';
|
||||
import { environment } from './environments/environment';
|
||||
|
||||
getTranslationProviders().then(providers => {
|
||||
const options = { providers };
|
||||
platformBrowserDynamic().bootstrapModule(AppModule, options);
|
||||
});
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
// #docregion
|
||||
/*
|
||||
SystemJS Text plugin from
|
||||
https://github.com/systemjs/plugin-text/blob/master/text.js
|
||||
*/
|
||||
exports.translate = function (load) {
|
||||
if (this.builder && this.transpiler) {
|
||||
load.metadata.format = 'esm';
|
||||
return 'exp' + 'ort var __useDefault = true; exp' + 'ort default ' + JSON.stringify(load.source) + ';';
|
||||
}
|
||||
|
||||
load.metadata.format = 'amd';
|
||||
return 'def' + 'ine(function() {\nreturn ' + JSON.stringify(load.source) + ';\n});';
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"files":[
|
||||
"!dist/",
|
||||
"!**/*.d.ts",
|
||||
"!src/**/*.js",
|
||||
"!doc-files/**/*",
|
||||
"**/*.xlf"
|
||||
],
|
||||
"removeSystemJsConfig": true,
|
||||
"type": "i18n"
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -46,6 +46,8 @@ Here you find a:
|
|||
* **base.json** - All the common scripts and packages
|
||||
* **cli.json** - Extra scripts and packages for the CLI
|
||||
* **webpack.json** - Extra scripts and packages for Webpack
|
||||
* **universal.json** - Extra scripts and packages for universal
|
||||
* **i18n.json** - Extra scripts and packages for i18n
|
||||
* **systemjs.json** - All the System.js related packages but it also contains the remainder scripts
|
||||
that are not in the other files.
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"scripts": [
|
||||
{ "name": "start", "command": "ng serve --aot" },
|
||||
{ "name": "start:fr", "command": "ng serve --aot --i18nFile=src/locale/messages.fr.xlf --i18nFormat=xlf --locale=fr" },
|
||||
{ "name": "build", "command": "ng build --prod" },
|
||||
{ "name": "build:fr", "command": "ng build --prod --i18nFile=src/locale/messages.fr.xlf --i18nFormat=xlf --locale=fr" },
|
||||
{ "name": "test", "command": "ng test" },
|
||||
{ "name": "lint", "command": "ng lint" },
|
||||
{ "name": "e2e", "command": "ng e2e --aot --i18nFile=src/locale/messages.fr.xlf --i18nFormat=xlf --locale=fr" },
|
||||
{ "name": "extract", "command": "ng xi18n --outputPath=src/locale" }
|
||||
],
|
||||
"dependencies": [
|
||||
"web-animations-js"
|
||||
],
|
||||
"devDependencies": [
|
||||
"@angular/cli",
|
||||
"@types/jasminewd2",
|
||||
"karma-coverage-istanbul-reporter",
|
||||
"ts-node"
|
||||
]
|
||||
}
|
|
@ -20,7 +20,6 @@ const IGNORED_EXAMPLES = [ // temporary ignores
|
|||
'quickstart',
|
||||
'http',
|
||||
'setup',
|
||||
'i18n',
|
||||
'webpack',
|
||||
'upgrade-p'
|
||||
];
|
||||
|
@ -203,7 +202,7 @@ function runProtractorAoT(appDir, outputFile) {
|
|||
// CLI version
|
||||
function runE2eTestsCLI(appDir, outputFile) {
|
||||
// --preserve-symlinks is needed due the symlinked node_modules in each example
|
||||
const e2eSpawn = spawnExt('ng', ['e2e', '--preserve-symlinks'], { cwd: appDir });
|
||||
const e2eSpawn = spawnExt('yarn', ['e2e', '--preserve-symlinks'], { cwd: appDir });
|
||||
return e2eSpawn.promise.then(
|
||||
function () {
|
||||
fs.appendFileSync(outputFile, `Passed: ${appDir}\n\n`);
|
||||
|
|
Loading…
Reference in New Issue