Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 9fd3fa0

Browse files
Foxandxsswardbell
authored andcommitted
docs(i18n): add new features (#2740)
1 parent 4a53673 commit 9fd3fa0

16 files changed

+466
-109
lines changed
Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict'; // necessary for es6 output in node
1+
'use strict'; // necessary for es6 output in node
22

33
import { browser, element, by } from 'protractor';
44

@@ -8,8 +8,26 @@ describe('i18n E2E Tests', () => {
88
browser.get('');
99
});
1010

11-
it('should display i18n translated welcome: Bonjour i18n!', function () {
12-
expect(element(by.css('h1')).getText()).toEqual('Bonjour i18n!');
11+
it('should display i18n translated welcome: ¡Hola i18n!', function () {
12+
expect(element(by.css('h1')).getText()).toEqual('¡Hola i18n!');
13+
});
14+
15+
it('should display the node texts without elements', function () {
16+
expect(element(by.css('my-app')).getText()).toContain('No genero ningún elemento');
17+
expect(element(by.css('my-app')).getText()).toContain('Yo tampoco genero ningún elemento');
18+
});
19+
20+
it('should display the translated title attribute', function () {
21+
const title = element(by.css('img')).getAttribute('title');
22+
expect(title).toBe('Logo de Angular 2');
23+
});
24+
25+
it('should display the plural of: a horde of wolves', function () {
26+
expect(element.all(by.css('span')).get(0).getText()).toBe('ningún lobo');
27+
});
28+
29+
it('should display the select of gender', function () {
30+
expect(element.all(by.css('span')).get(1).getText()).toBe('El heroe es mujer');
1331
});
1432

1533
});
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
**/*.ngfactory.ts
22
**/*.metadata.json
3-
**/messages.xlf
43
dist
54
!app/tsconfig.json
6-
!rollup.js
5+
!rollup.js

public/docs/_examples/cb-i18n/ts/app/app.component.1.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ <h1 i18n>Hello i18n!</h1>
99
<!--#docregion i18n-attribute-desc-->
1010
<h1 i18n="An introduction header for this sample">Hello i18n!</h1>
1111
<!--#enddocregion i18n-attribute-desc-->
12+
13+
<!--#docregion i18n-title-->
14+
<img [src]="logo" title="Angular 2 logo">
15+
<!--#enddocregion i18n-title-->
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
11
<!--#docregion-->
22
<!--#docregion i18n-attribute-meaning-->
33
<h1 i18n="User welcome|An introduction header for this sample">Hello i18n!</h1>
4-
<!--#enddocregion i18n-attribute-meaning-->
4+
<!--#enddocregion i18n-attribute-meaning-->
5+
6+
<!--#docregion i18n-ng-container-->
7+
<ng-container i18n>I don't output any element</ng-container>
8+
<!--#enddocregion i18n-ng-container-->
9+
10+
<br />
11+
12+
<!--#docregion i18n-with-comment-->
13+
<!--i18n: optional meaning|optional description -->
14+
I don't output any element either
15+
<!--/i18n-->
16+
<!--#enddocregion i18n-with-comment-->
17+
18+
<br />
19+
20+
<!--#docregion i18n-title-translate-->
21+
<img [src]="logo" i18n-title title="Angular 2 logo" />
22+
<!--#enddocregion i18n-title-translate-->
23+
<br>
24+
<button (click)="inc(1)">+</button> <button (click)="inc(-1)">-</button>
25+
<!--#docregion i18n-plural-->
26+
<span i18n>{wolves, plural, =0 {no wolves} =1 {one wolf} =2 {two wolves} other {a wolf pack}}</span>
27+
<!--#enddocregion i18n-plural-->
28+
({{wolves}})
29+
<br><br>
30+
<button (click)="male()">&#9794;</button> <button (click)="female()">&#9792;</button>
31+
<!--#docregion i18n-select-->
32+
<span i18n>The hero is {gender, select, m {male} f {female}}</span>
33+
<!--#enddocregion i18n-select-->
34+
<br>

public/docs/_examples/cb-i18n/ts/app/app.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,15 @@ import { Component } from '@angular/core';
66
selector: 'my-app',
77
templateUrl: 'app.component.html'
88
})
9-
export class AppComponent { }
9+
export class AppComponent {
10+
wolves = 0;
11+
gender = 'f';
12+
fly = true;
13+
logo = 'https://angular.io/resources/images/logos/angular2/angular.png';
14+
inc(i: number) {
15+
this.wolves = Math.min(5, Math.max(0, this.wolves + i));
16+
}
17+
male() { this.gender = 'm'; }
18+
female() { this.gender = 'f'; }
19+
}
1020

public/docs/_examples/cb-i18n/ts/app/i18n-providers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function getTranslationProviders(): Promise<Object[]> {
1414
return Promise.resolve(noProviders);
1515
}
1616

17-
// Ex: 'locale/messages.fr.xlf`
17+
// Ex: 'locale/messages.es.xlf`
1818
const translationFile = `./locale/messages.${locale}.xlf`;
1919

2020
return getTranslationsWithSystemJs(translationFile)

public/docs/_examples/cb-i18n/ts/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<!-- #docregion i18n -->
1919
<script>
2020
// Get the locale id somehow
21-
document.locale = 'fr';
21+
document.locale = 'es';
2222

2323
// Map to the text plugin
2424
System.config({
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="ng2.template">
4+
<body>
5+
<trans-unit id="af2ccf4b5dba59616e92cf1531505af02da8f6d2" datatype="html">
6+
<source>Hello i18n!</source>
7+
<target>¡Hola i18n!</target>
8+
<note priority="1" from="description">An introduction header for this sample</note>
9+
<note priority="1" from="meaning">User welcome</note>
10+
</trans-unit>
11+
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
12+
<source>I don&apos;t output any element</source>
13+
<target>No genero ningún elemento</target>
14+
</trans-unit>
15+
<trans-unit id="df3cf8b55cb528cf8c00167e0b119bfb828538b5" datatype="html">
16+
<source>
17+
I don&apos;t output any element either
18+
</source>
19+
<target>Yo tampoco genero ningún elemento</target>
20+
<note priority="1" from="description">optional description</note>
21+
<note priority="1" from="meaning">optional meaning</note>
22+
</trans-unit>
23+
<trans-unit id="35ab5d6121ecbe0decdda638571a5a55ac77d5c4" datatype="html">
24+
<source>Angular 2 logo</source>
25+
<target>Logo de Angular 2</target>
26+
</trans-unit>
27+
<trans-unit id="6e22e74e8cbd3095560cfe08993c4fdfa3c50eb0" datatype="html">
28+
<source/>
29+
<target>{wolves, plural, =0 {ningún lobo} =1 {un lobo} =2 {dos lobos} other {una horda de lobos}}</target>
30+
</trans-unit>
31+
<trans-unit id="61cafedb85466ab789b3ae817bba1a545468ee1c" datatype="html">
32+
<source>The hero is <x id="ICU"/></source>
33+
<target>El heroe es <x id="ICU"/></target>
34+
</trans-unit>
35+
<trans-unit id="14c7055d67771a3b7b6888d282ac092896be06b6" datatype="html">
36+
<source/>
37+
<target>{gender, select, m {hombre} f {mujer}}</target>
38+
</trans-unit>
39+
</body>
40+
</file>
41+
</xliff>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!-- The `messages.es.xlf` after translation for documentation purposes -->
2+
<!-- #docregion -->
3+
<?xml version="1.0" encoding="UTF-8" ?>
4+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
5+
<file source-language="en" datatype="plaintext" original="ng2.template">
6+
<body>
7+
<!-- #docregion translated-hello -->
8+
<trans-unit id="af2ccf4b5dba59616e92cf1531505af02da8f6d2" datatype="html">
9+
<source>Hello i18n!</source>
10+
<target>¡Hola i18n!</target>
11+
<note priority="1" from="description">An introduction header for this sample</note>
12+
<note priority="1" from="meaning">User welcome</note>
13+
</trans-unit>
14+
<!-- #enddocregion translated-hello -->
15+
<!-- #docregion translated-other-nodes -->
16+
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
17+
<source>I don&apos;t output any element</source>
18+
<target>No genero ningún elemento</target>
19+
</trans-unit>
20+
<trans-unit id="df3cf8b55cb528cf8c00167e0b119bfb828538b5" datatype="html">
21+
<source>I don&apos;t output any element either</source>
22+
<target>Yo tampoco genero ningún elemento</target>
23+
<note priority="1" from="description">optional description</note>
24+
<note priority="1" from="meaning">optional meaning</note>
25+
</trans-unit>
26+
<trans-unit id="35ab5d6121ecbe0decdda638571a5a55ac77d5c4" datatype="html">
27+
<source>Angular 2 logo</source>
28+
<target>Logo de Angular 2</target>
29+
</trans-unit>
30+
<!-- #enddocregion translated-other-nodes -->
31+
<!-- #docregion translated-plural -->
32+
<trans-unit id="6e22e74e8cbd3095560cfe08993c4fdfa3c50eb0" datatype="html">
33+
<source/>
34+
<target>{wolves, plural, =0 {ningún lobo} =1 {un lobo} =2 {dos lobos} other {una horda de lobos}}</target>
35+
</trans-unit>
36+
<!-- #enddocregion translated-plural -->
37+
<!-- #docregion translated-select -->
38+
<!-- #docregion translate-select-1 -->
39+
<trans-unit id="61cafedb85466ab789b3ae817bba1a545468ee1c" datatype="html">
40+
<source>The hero is <x id="ICU"/></source>
41+
<target>El heroe es <x id="ICU"/></target>
42+
</trans-unit>
43+
<!-- #enddocregion translate-select-1 -->
44+
<!-- #docregion translate-select-2 -->
45+
<trans-unit id="14c7055d67771a3b7b6888d282ac092896be06b6" datatype="html">
46+
<source/>
47+
<target>{gender, select, m {hombre} f {mujer}}</target>
48+
</trans-unit>
49+
<!-- #enddocregion translate-select-2 -->
50+
<!-- #enddocregion translated-select -->
51+
</body>
52+
</file>
53+
</xliff>
54+

public/docs/_examples/cb-i18n/ts/locale/messages.fr.xlf

Lines changed: 0 additions & 13 deletions
This file was deleted.

public/docs/_examples/cb-i18n/ts/locale/messages.fr.xlf.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

public/docs/_examples/cb-i18n/ts/locale/trans-unit.html

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="ng2.template">
4+
<body>
5+
<trans-unit id="af2ccf4b5dba59616e92cf1531505af02da8f6d2" datatype="html">
6+
<source>Hello i18n!</source>
7+
<target/>
8+
<note priority="1" from="description">An introduction header for this sample</note>
9+
<note priority="1" from="meaning">User welcome</note>
10+
</trans-unit>
11+
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
12+
<source>I don&apos;t output any element</source>
13+
<target/>
14+
</trans-unit>
15+
<trans-unit id="df3cf8b55cb528cf8c00167e0b119bfb828538b5" datatype="html">
16+
<source>
17+
I don&apos;t output any element either
18+
</source>
19+
<target/>
20+
<note priority="1" from="description">optional description</note>
21+
<note priority="1" from="meaning">optional meaning</note>
22+
</trans-unit>
23+
<trans-unit id="35ab5d6121ecbe0decdda638571a5a55ac77d5c4" datatype="html">
24+
<source>Angular 2 logo</source>
25+
<target/>
26+
</trans-unit>
27+
<trans-unit id="6e22e74e8cbd3095560cfe08993c4fdfa3c50eb0" datatype="html">
28+
<source/>
29+
<target/>
30+
</trans-unit>
31+
<trans-unit id="61cafedb85466ab789b3ae817bba1a545468ee1c" datatype="html">
32+
<source>The hero is <x id="ICU"/></source>
33+
<target/>
34+
</trans-unit>
35+
<trans-unit id="14c7055d67771a3b7b6888d282ac092896be06b6" datatype="html">
36+
<source/>
37+
<target/>
38+
</trans-unit>
39+
</body>
40+
</file>
41+
</xliff>

public/docs/_examples/cb-i18n/ts/plnkr.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"app/**/*.css",
55
"app/**/*.html",
66
"app/**/*.ts",
7-
"locale/messages.xlf",
8-
"locale/messages.fr.xlf",
7+
"messages.xlf",
8+
"locale/messages.*.xlf",
99

1010
"!**/*.[1].*",
1111

0 commit comments

Comments
 (0)