-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(aio): updated i18n guide and example
- Loading branch information
Showing
49 changed files
with
1,288 additions
and
667 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { } |
6 changes: 6 additions & 0 deletions
6
aio/content/examples/i18n/src/main.1.ts → ...content/examples/i18n/doc-files/main.1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'} | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [ | ||
// ... | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; // necessary for es6 output in node | ||
|
||
import { browser, element, by } from 'protractor'; | ||
|
||
// disable until we get cli 1.5+ and angular 5+ to be able to run this | ||
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`); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"projectType": "i18n" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.