From 9fd3fa037d24b46da6b67bb061ce8c856932aa94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Rodr=C3=ADguez?= Date: Sat, 3 Dec 2016 02:25:31 +0100 Subject: [PATCH] docs(i18n): add new features (#2740) --- public/docs/_examples/cb-i18n/e2e-spec.ts | 24 +- public/docs/_examples/cb-i18n/ts/.gitignore | 3 +- .../cb-i18n/ts/app/app.component.1.html | 4 + .../cb-i18n/ts/app/app.component.html | 32 +- .../_examples/cb-i18n/ts/app/app.component.ts | 12 +- .../cb-i18n/ts/app/i18n-providers.ts | 2 +- public/docs/_examples/cb-i18n/ts/index.html | 2 +- .../cb-i18n/ts/locale/messages.es.xlf | 41 +++ .../cb-i18n/ts/locale/messages.es.xlf.html | 54 +++ .../cb-i18n/ts/locale/messages.fr.xlf | 13 - .../cb-i18n/ts/locale/messages.fr.xlf.html | 17 - .../cb-i18n/ts/locale/trans-unit.html | 7 - public/docs/_examples/cb-i18n/ts/messages.xlf | 41 +++ public/docs/_examples/cb-i18n/ts/plnkr.json | 4 +- public/docs/ts/latest/cookbook/i18n.jade | 314 ++++++++++++++---- public/docs/ts/latest/guide/change-log.jade | 5 + 16 files changed, 466 insertions(+), 109 deletions(-) create mode 100644 public/docs/_examples/cb-i18n/ts/locale/messages.es.xlf create mode 100644 public/docs/_examples/cb-i18n/ts/locale/messages.es.xlf.html delete mode 100644 public/docs/_examples/cb-i18n/ts/locale/messages.fr.xlf delete mode 100644 public/docs/_examples/cb-i18n/ts/locale/messages.fr.xlf.html delete mode 100644 public/docs/_examples/cb-i18n/ts/locale/trans-unit.html create mode 100644 public/docs/_examples/cb-i18n/ts/messages.xlf diff --git a/public/docs/_examples/cb-i18n/e2e-spec.ts b/public/docs/_examples/cb-i18n/e2e-spec.ts index f3249272af..ee66ff6683 100644 --- a/public/docs/_examples/cb-i18n/e2e-spec.ts +++ b/public/docs/_examples/cb-i18n/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; @@ -8,8 +8,26 @@ describe('i18n E2E Tests', () => { browser.get(''); }); - it('should display i18n translated welcome: Bonjour i18n!', function () { - expect(element(by.css('h1')).getText()).toEqual('Bonjour i18n!'); + 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'); + expect(element(by.css('my-app')).getText()).toContain('Yo tampoco 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 2'); + }); + + 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'); }); }); diff --git a/public/docs/_examples/cb-i18n/ts/.gitignore b/public/docs/_examples/cb-i18n/ts/.gitignore index 8357331dc7..0aa8a6416f 100644 --- a/public/docs/_examples/cb-i18n/ts/.gitignore +++ b/public/docs/_examples/cb-i18n/ts/.gitignore @@ -1,6 +1,5 @@ **/*.ngfactory.ts **/*.metadata.json -**/messages.xlf dist !app/tsconfig.json -!rollup.js \ No newline at end of file +!rollup.js diff --git a/public/docs/_examples/cb-i18n/ts/app/app.component.1.html b/public/docs/_examples/cb-i18n/ts/app/app.component.1.html index 7813de7d31..cc19182338 100644 --- a/public/docs/_examples/cb-i18n/ts/app/app.component.1.html +++ b/public/docs/_examples/cb-i18n/ts/app/app.component.1.html @@ -9,3 +9,7 @@

Hello i18n!

+ + + + diff --git a/public/docs/_examples/cb-i18n/ts/app/app.component.html b/public/docs/_examples/cb-i18n/ts/app/app.component.html index 3469b42e86..7c5562bece 100644 --- a/public/docs/_examples/cb-i18n/ts/app/app.component.html +++ b/public/docs/_examples/cb-i18n/ts/app/app.component.html @@ -1,4 +1,34 @@

Hello i18n!

- \ No newline at end of file + + + +I don't output any element + + +
+ + + +I don't output any element either + + + +
+ + + + +
+ + +{wolves, plural, =0 {no wolves} =1 {one wolf} =2 {two wolves} other {a wolf pack}} + +({{wolves}}) +

+ + +The hero is {gender, select, m {male} f {female}} + +
diff --git a/public/docs/_examples/cb-i18n/ts/app/app.component.ts b/public/docs/_examples/cb-i18n/ts/app/app.component.ts index e065c38917..e8f93321a4 100644 --- a/public/docs/_examples/cb-i18n/ts/app/app.component.ts +++ b/public/docs/_examples/cb-i18n/ts/app/app.component.ts @@ -6,5 +6,15 @@ import { Component } from '@angular/core'; selector: 'my-app', templateUrl: 'app.component.html' }) -export class AppComponent { } +export class AppComponent { + wolves = 0; + gender = 'f'; + fly = true; + logo = 'https://angular.io/resources/images/logos/angular2/angular.png'; + inc(i: number) { + this.wolves = Math.min(5, Math.max(0, this.wolves + i)); + } + male() { this.gender = 'm'; } + female() { this.gender = 'f'; } +} diff --git a/public/docs/_examples/cb-i18n/ts/app/i18n-providers.ts b/public/docs/_examples/cb-i18n/ts/app/i18n-providers.ts index 84328f0d22..f0bb662dc3 100644 --- a/public/docs/_examples/cb-i18n/ts/app/i18n-providers.ts +++ b/public/docs/_examples/cb-i18n/ts/app/i18n-providers.ts @@ -14,7 +14,7 @@ export function getTranslationProviders(): Promise { return Promise.resolve(noProviders); } - // Ex: 'locale/messages.fr.xlf` + // Ex: 'locale/messages.es.xlf` const translationFile = `./locale/messages.${locale}.xlf`; return getTranslationsWithSystemJs(translationFile) diff --git a/public/docs/_examples/cb-i18n/ts/index.html b/public/docs/_examples/cb-i18n/ts/index.html index fc88d9284e..9a5fa496c5 100644 --- a/public/docs/_examples/cb-i18n/ts/index.html +++ b/public/docs/_examples/cb-i18n/ts/index.html @@ -18,7 +18,7 @@