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

Commit 30f7c9f

Browse files
Foxandxsswardbell
authored andcommitted
docs(i18n): add new features
1 parent c7717b4 commit 30f7c9f

File tree

13 files changed

+321
-61
lines changed

13 files changed

+321
-61
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 alt attribute', function () {
21+
const alt = element(by.css('img')).getAttribute('alt');
22+
expect(alt).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('div')).get(0).getText()).toBe('una horda de lobos');
27+
});
28+
29+
it('should display the select of sex', function () {
30+
expect(element.all(by.css('div')).get(1).getText()).toBe('El heroe es mujer');
1331
});
1432

1533
});

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-alt-->
14+
<img [src]="logo" alt="Angular 2 logo">
15+
<!--#enddocregion i18n-alt-->
Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
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-alt-translate-->
21+
<img [src]="logo" i18n-alt alt="Angular 2 logo" />
22+
<!--#enddocregion i18n-alt-translate-->
23+
24+
<!--#docregion i18n-plural-->
25+
<div i18n>{wolves, plural, zero {no wolves} =1 {one wolf} two {two wolves} other {a horde of wolves}}</div>
26+
<!--#enddocregion i18n-plural-->
27+
28+
<!--#docregion i18n-select-->
29+
<div i18n>The hero is {sex, select, m {male} f {female}}</div>
30+
<!--#enddocregion i18n-select-->

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,10 @@ 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 = 5;
11+
sex = 'f';
12+
fly = true;
13+
logo = 'https://angular.io/resources/images/logos/angular2/angular.png';
14+
}
1015

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="fd3463eb234ef776cae5f7d9a8efa19c3fd3f959" datatype="html">
28+
<source/>
29+
<target>{wolves, plural, zero {ningún lobo} =1 {un lobo} two {dos lobos} other {una horda de lobos}}</target>
30+
</trans-unit>
31+
<trans-unit id="989a4716b006c7bd26c4dfd9bc45dc6c792e34b1" 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="c0ca5e58fe954d528bbfa516007a5a11690a7e99" datatype="html">
36+
<source/>
37+
<target>{sex, select, m {hombre} f {mujer}}</target>
38+
</trans-unit>
39+
</body>
40+
</file>
41+
</xliff>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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="fd3463eb234ef776cae5f7d9a8efa19c3fd3f959" datatype="html">
33+
<source/>
34+
<target>{wolves, plural, zero {ningún lobo} =1 {un lobo} two {dos lobos} other {una horda de lobos}}</target>
35+
</trans-unit>
36+
<!-- #enddocregion translated-plural -->
37+
<!-- #docregion translated-select -->
38+
<trans-unit id="989a4716b006c7bd26c4dfd9bc45dc6c792e34b1" datatype="html">
39+
<source>The hero is <x id="ICU"/></source>
40+
<target>El heroe es <x id="ICU"/></target>
41+
</trans-unit>
42+
<trans-unit id="c0ca5e58fe954d528bbfa516007a5a11690a7e99" datatype="html">
43+
<source/>
44+
<target>{sex, select, m {hombre} f {mujer}}</target>
45+
</trans-unit>
46+
<!-- #enddocregion translated-select -->
47+
</body>
48+
</file>
49+
</xliff>
50+

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.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
11
<!-- #docregion -->
2+
<!-- #docregion translate-hello -->
23
<trans-unit id="af2ccf4b5dba59616e92cf1531505af02da8f6d2" datatype="html">
34
<source>Hello i18n!</source>
45
<target/>
56
<note priority="1" from="description">An introduction header for this sample</note>
67
<note priority="1" from="meaning">User welcome</note>
78
</trans-unit>
9+
<!-- #enddocregion translate-hello -->
10+
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>I don&apos;t output any element either</source>
17+
<target/>
18+
<note priority="1" from="description">optional description</note>
19+
<note priority="1" from="meaning">optional meaning</note>
20+
</trans-unit>
21+
<trans-unit id="35ab5d6121ecbe0decdda638571a5a55ac77d5c4" datatype="html">
22+
<source>Angular 2 logo</source>
23+
<target/>
24+
</trans-unit>
25+
<trans-unit id="fd3463eb234ef776cae5f7d9a8efa19c3fd3f959" datatype="html">
26+
<source/>
27+
<target/>
28+
</trans-unit>
29+
<!-- #docregion translate-select-node -->
30+
<trans-unit id="989a4716b006c7bd26c4dfd9bc45dc6c792e34b1" datatype="html">
31+
<source>The hero is <x id="ICU"/></source>
32+
<target/>
33+
</trans-unit>
34+
<!-- #enddocregion translate-select-node -->
35+
<trans-unit id="c0ca5e58fe954d528bbfa516007a5a11690a7e99" datatype="html">
36+
<source/>
37+
<target/>
38+
</trans-unit>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"app/**/*.html",
66
"app/**/*.ts",
77
"locale/messages.xlf",
8-
"locale/messages.fr.xlf",
8+
"locale/messages.es.xlf",
99

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

0 commit comments

Comments
 (0)