This repository was archived by the owner on Dec 4, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 875
[BACKUP] new I18n guide #2340
Closed
Closed
[BACKUP] new I18n guide #2340
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
68fdbce
docs(guide): document internationalization (i18n)
ocombe cb7225e
Jesus' tweaks
Foxandxss 3552db7
docs(i18n): fix _data.json
wardbell b3e44c8
chore: remove typescript installation instruction
Foxandxss 17ed3ca
angular 2 -> angular
filipesilva f727149
Merge remote-tracking branch 'upstream/master' into i18n-guide
filipesilva dc9bd4d
add base jit app
filipesilva 586f47e
wording fixes
filipesilva 76848c4
add translated jit example
filipesilva 1576c08
add e2e test
filipesilva c48eff3
add jit plunker support
filipesilva a726076
remove references to reloading
filipesilva c3e219c
remove comparison of server requirements
filipesilva e413ae9
replace directive with attribute
filipesilva 94b6ea2
explain relevant of meaning in i18n
filipesilva ce1de16
replace git and specialized translation software for versioning
filipesilva 89e45d7
remove dynamic language switching
filipesilva 8b8ccf2
remove pipe usage
filipesilva 635b4e4
edit prose
filipesilva 3373fad
fix code shell example
filipesilva e842200
incorporate vicb's feedback
filipesilva 6ff5c74
fix typo
filipesilva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,19 @@ | ||
/// <reference path='../_protractor/e2e.d.ts' /> | ||
'use strict'; | ||
describe('QuickStart E2E Tests', function () { | ||
|
||
let expectedMsg = 'Hello from Angular 2 App with i18n'; | ||
|
||
beforeEach(function () { | ||
browser.get(''); | ||
}); | ||
|
||
it(`should display: ${expectedMsg}`, function () { | ||
expect(element(by.css('h1')).getText()).toEqual(expectedMsg); | ||
}); | ||
|
||
it('should display an image', function () { | ||
expect(element(by.css('img')).isPresent()).toBe(true); | ||
}); | ||
|
||
}); |
106 changes: 106 additions & 0 deletions
106
public/docs/_examples/i18n/ts-snippets/i18n.config.snippets.ts
This file contains hidden or 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,106 @@ | ||
/* tslint:disable */ | ||
// #docregion i18n-directive | ||
<h1 i18n>Hello i18n</h1> | ||
// #enddocregion i18n-directive | ||
|
||
// #docregion i18n-directive-desc | ||
<h1 i18n="An introduction header for this sample">Hello i18n</h1> | ||
// #enddocregion i18n-directive-desc | ||
|
||
// #docregion i18n-directive-meaning | ||
<h1 i18n="User welcome|An introduction header for this sample">Hello i18n</h1> | ||
// #enddocregion i18n-directive-meaning | ||
|
||
// #docregion i18n-plural-pipe | ||
@Component({ | ||
selector: 'my-app', | ||
template: ` | ||
<div> | ||
{{ messages.length | i18nPlural: messageMapping }} | ||
</div> | ||
` | ||
}) | ||
export class AppComponent { | ||
messages: string[]; | ||
messageMapping: {[k:string]: string} = { | ||
'=0': 'No messages.', | ||
'=1': 'One message.', | ||
'other': '# messages.' | ||
} | ||
} | ||
// #enddocregion i18n-plural-pipe | ||
|
||
// #docregion i18n-select-pipe | ||
@Component({ | ||
selector: 'my-app', | ||
template: ` | ||
<div> | ||
{{ gender | i18nSelect: genderMap }} | ||
</div> | ||
` | ||
}) | ||
export class AppComponent { | ||
gender = 'male'; | ||
genderMap = { | ||
'male': 'Invite him.', | ||
'female': 'Invite her.', | ||
'other': 'Invite them.' | ||
} | ||
} | ||
// #enddocregion i18n-select-pipe | ||
|
||
// #docregion tsconfig | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"removeComments": false, | ||
"noImplicitAny": true, | ||
"suppressImplicitAnyIndexErrors": true | ||
}, | ||
"angularCompilerOptions": { | ||
"genDir": "./app/i18n" | ||
} | ||
} | ||
// #enddocregion tsconfig | ||
|
||
// #docregion bootstrap | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
|
||
import { AppModule } from './app.module'; | ||
|
||
platformBrowserDynamic().bootstrapModule(AppModule); | ||
// #enddocregion bootstrap | ||
|
||
// #docregion bootstrap-i18n | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID } from '@angular/core'; | ||
|
||
import { AppModule } from './app.module'; | ||
import { TRANSLATION } from './i18n/messages.fr'; | ||
|
||
// Compile using french translations | ||
platformBrowserDynamic().bootstrapModule( | ||
AppModule, | ||
{ | ||
providers: [ | ||
{provide: TRANSLATIONS, useValue: TRANSLATION}, | ||
{provide: TRANSLATIONS_FORMAT, useValue: 'xlf'}, | ||
{provide: LOCALE_ID, useValue: 'fr'} | ||
] | ||
} | ||
); | ||
// #enddocregion bootstrap-i18n | ||
|
||
// #docregion messages-ts | ||
export const TRANSLATION = `<?xml version="1.0" encoding="UTF-8"?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI this will be in CompilerConfig soon, I'll try to remember to cc the doc team on the PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have an ETA on that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. started working on that. probably 2.1 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, I'll leave it as is for now then we'll update it. |
||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2"> | ||
<file source-language="en" datatype="plaintext" original="ng2.template" target-language="fr-fr"> | ||
... | ||
</file> | ||
</xliff>`; | ||
// #enddocregion messages-ts |
This file contains hidden or 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 @@ | ||
!= partial("../../../_includes/_ts-temp") |
This file contains hidden or 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 @@ | ||
!= partial("../../../_includes/_ts-temp") |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better use
one
andother
which is the standard for enThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=0
remains the same?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one and other are caterogies, =x is for discrete values, works with any x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done