docs(aio): rename cb- files and a few others
This commit is contained in:

committed by
Pete Bacon Darwin

parent
c3fa8803d3
commit
93516ea8a1
15
aio/content/examples/i18n/src/app/app.component.1.html
Normal file
15
aio/content/examples/i18n/src/app/app.component.1.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!--#docregion greeting-->
|
||||
<h1>Hello i18n!</h1>
|
||||
<!--#enddocregion greeting-->
|
||||
|
||||
<!--#docregion i18n-attribute-->
|
||||
<h1 i18n>Hello i18n!</h1>
|
||||
<!--#enddocregion i18n-attribute-->
|
||||
|
||||
<!--#docregion i18n-attribute-desc-->
|
||||
<h1 i18n="An introduction header for this sample">Hello i18n!</h1>
|
||||
<!--#enddocregion i18n-attribute-desc-->
|
||||
|
||||
<!--#docregion i18n-title-->
|
||||
<img [src]="logo" title="Angular logo">
|
||||
<!--#enddocregion i18n-title-->
|
34
aio/content/examples/i18n/src/app/app.component.html
Normal file
34
aio/content/examples/i18n/src/app/app.component.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!--#docregion-->
|
||||
<!--#docregion i18n-attribute-meaning-->
|
||||
<h1 i18n="User welcome|An introduction header for this sample">Hello i18n!</h1>
|
||||
<!--#enddocregion i18n-attribute-meaning-->
|
||||
|
||||
<!--#docregion i18n-ng-container-->
|
||||
<ng-container i18n>I don't output any element</ng-container>
|
||||
<!--#enddocregion i18n-ng-container-->
|
||||
|
||||
<br />
|
||||
|
||||
<!--#docregion i18n-with-comment-->
|
||||
<!--i18n: optional meaning|optional description -->
|
||||
I don't output any element either
|
||||
<!--/i18n-->
|
||||
<!--#enddocregion i18n-with-comment-->
|
||||
|
||||
<br />
|
||||
|
||||
<!--#docregion i18n-title-translate-->
|
||||
<img [src]="logo" i18n-title title="Angular logo" />
|
||||
<!--#enddocregion i18n-title-translate-->
|
||||
<br>
|
||||
<button (click)="inc(1)">+</button> <button (click)="inc(-1)">-</button>
|
||||
<!--#docregion i18n-plural-->
|
||||
<span i18n>{wolves, plural, =0 {no wolves} =1 {one wolf} =2 {two wolves} other {a wolf pack}}</span>
|
||||
<!--#enddocregion i18n-plural-->
|
||||
({{wolves}})
|
||||
<br><br>
|
||||
<button (click)="male()">♂</button> <button (click)="female()">♀</button>
|
||||
<!--#docregion i18n-select-->
|
||||
<span i18n>The hero is {gender, select, m {male} f {female}}</span>
|
||||
<!--#enddocregion i18n-select-->
|
||||
<br>
|
19
aio/content/examples/i18n/src/app/app.component.ts
Normal file
19
aio/content/examples/i18n/src/app/app.component.ts
Normal file
@ -0,0 +1,19 @@
|
||||
// #docregion
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
templateUrl: './app.component.html'
|
||||
})
|
||||
export class AppComponent {
|
||||
wolves = 0;
|
||||
gender = 'f';
|
||||
fly = true;
|
||||
logo = 'https://angular.io/resources/images/logos/angular/angular.png';
|
||||
inc(i: number) {
|
||||
this.wolves = Math.min(5, Math.max(0, this.wolves + i));
|
||||
}
|
||||
male() { this.gender = 'm'; }
|
||||
female() { this.gender = 'f'; }
|
||||
}
|
||||
|
13
aio/content/examples/i18n/src/app/app.module.ts
Normal file
13
aio/content/examples/i18n/src/app/app.module.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// #docregion
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [ BrowserModule ],
|
||||
declarations: [ AppComponent ],
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
|
||||
export class AppModule { }
|
33
aio/content/examples/i18n/src/app/i18n-providers.ts
Normal file
33
aio/content/examples/i18n/src/app/i18n-providers.ts
Normal file
@ -0,0 +1,33 @@
|
||||
// #docregion
|
||||
import { TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID } from '@angular/core';
|
||||
|
||||
export function getTranslationProviders(): Promise<Object[]> {
|
||||
|
||||
// Get the locale id from the global
|
||||
const locale = document['locale'] as string;
|
||||
|
||||
// return no providers if fail to get translation file for locale
|
||||
const noProviders: Object[] = [];
|
||||
|
||||
// No locale or U.S. English: no translation providers
|
||||
if (!locale || locale === 'en-US') {
|
||||
return Promise.resolve(noProviders);
|
||||
}
|
||||
|
||||
// Ex: 'locale/messages.es.xlf`
|
||||
const translationFile = `./locale/messages.${locale}.xlf`;
|
||||
|
||||
return getTranslationsWithSystemJs(translationFile)
|
||||
.then( (translations: string ) => [
|
||||
{ provide: TRANSLATIONS, useValue: translations },
|
||||
{ provide: TRANSLATIONS_FORMAT, useValue: 'xlf' },
|
||||
{ provide: LOCALE_ID, useValue: locale }
|
||||
])
|
||||
.catch(() => noProviders); // ignore if file not found
|
||||
}
|
||||
|
||||
declare var System: any;
|
||||
|
||||
function getTranslationsWithSystemJs(file: string) {
|
||||
return System.import(file + '!text'); // relies on text plugin
|
||||
}
|
39
aio/content/examples/i18n/src/index.html
Normal file
39
aio/content/examples/i18n/src/index.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- #docregion -->
|
||||
<html>
|
||||
<head>
|
||||
<title>Angular i18n example</title>
|
||||
<base href="/">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
|
||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||
|
||||
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||
|
||||
<script src="systemjs.config.js"></script>
|
||||
|
||||
<!-- #docregion i18n -->
|
||||
<script>
|
||||
// Get the locale id somehow
|
||||
document.locale = 'es';
|
||||
|
||||
// Map to the text plugin
|
||||
System.config({
|
||||
map: {
|
||||
text: 'systemjs-text-plugin.js'
|
||||
}
|
||||
});
|
||||
|
||||
// Launch the app
|
||||
System.import('main.js').catch(function(err){ console.error(err); });
|
||||
</script>
|
||||
<!-- #enddocregion i18n -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<my-app>Loading...</my-app>
|
||||
</body>
|
||||
</html>
|
41
aio/content/examples/i18n/src/locale/messages.es.xlf
Normal file
41
aio/content/examples/i18n/src/locale/messages.es.xlf
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<file source-language="en" datatype="plaintext" original="ng2.template">
|
||||
<body>
|
||||
<trans-unit id="af2ccf4b5dba59616e92cf1531505af02da8f6d2" datatype="html">
|
||||
<source>Hello i18n!</source>
|
||||
<target>¡Hola i18n!</target>
|
||||
<note priority="1" from="description">An introduction header for this sample</note>
|
||||
<note priority="1" from="meaning">User welcome</note>
|
||||
</trans-unit>
|
||||
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
|
||||
<source>I don't output any element</source>
|
||||
<target>No genero ningún elemento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="df3cf8b55cb528cf8c00167e0b119bfb828538b5" datatype="html">
|
||||
<source>
|
||||
I don't output any element either
|
||||
</source>
|
||||
<target>Yo tampoco genero ningún elemento</target>
|
||||
<note priority="1" from="description">optional description</note>
|
||||
<note priority="1" from="meaning">optional meaning</note>
|
||||
</trans-unit>
|
||||
<trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
|
||||
<source>Angular logo</source>
|
||||
<target>Logo de Angular</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6e22e74e8cbd3095560cfe08993c4fdfa3c50eb0" datatype="html">
|
||||
<source/>
|
||||
<target>{wolves, plural, =0 {ningún lobo} =1 {un lobo} =2 {dos lobos} other {una horda de lobos}}</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="61cafedb85466ab789b3ae817bba1a545468ee1c" datatype="html">
|
||||
<source>The hero is <x id="ICU"/></source>
|
||||
<target>El heroe es <x id="ICU"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="14c7055d67771a3b7b6888d282ac092896be06b6" datatype="html">
|
||||
<source/>
|
||||
<target>{gender, select, m {hombre} f {mujer}}</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
54
aio/content/examples/i18n/src/locale/messages.es.xlf.html
Normal file
54
aio/content/examples/i18n/src/locale/messages.es.xlf.html
Normal file
@ -0,0 +1,54 @@
|
||||
<!-- The `messages.es.xlf` after translation for documentation purposes -->
|
||||
<!-- #docregion -->
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<file source-language="en" datatype="plaintext" original="ng2.template">
|
||||
<body>
|
||||
<!-- #docregion translated-hello -->
|
||||
<trans-unit id="af2ccf4b5dba59616e92cf1531505af02da8f6d2" datatype="html">
|
||||
<source>Hello i18n!</source>
|
||||
<target>¡Hola i18n!</target>
|
||||
<note priority="1" from="description">An introduction header for this sample</note>
|
||||
<note priority="1" from="meaning">User welcome</note>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translated-hello -->
|
||||
<!-- #docregion translated-other-nodes -->
|
||||
<trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
|
||||
<source>I don't output any element</source>
|
||||
<target>No genero ningún elemento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="df3cf8b55cb528cf8c00167e0b119bfb828538b5" datatype="html">
|
||||
<source>I don't output any element either</source>
|
||||
<target>Yo tampoco genero ningún elemento</target>
|
||||
<note priority="1" from="description">optional description</note>
|
||||
<note priority="1" from="meaning">optional meaning</note>
|
||||
</trans-unit>
|
||||
<trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
|
||||
<source>Angular logo</source>
|
||||
<target>Logo de Angular</target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translated-other-nodes -->
|
||||
<!-- #docregion translated-plural -->
|
||||
<trans-unit id="6e22e74e8cbd3095560cfe08993c4fdfa3c50eb0" datatype="html">
|
||||
<source/>
|
||||
<target>{wolves, plural, =0 {ningún lobo} =1 {un lobo} =2 {dos lobos} other {una horda de lobos}}</target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translated-plural -->
|
||||
<!-- #docregion translated-select -->
|
||||
<!-- #docregion translate-select-1 -->
|
||||
<trans-unit id="61cafedb85466ab789b3ae817bba1a545468ee1c" datatype="html">
|
||||
<source>The hero is <x id="ICU"/></source>
|
||||
<target>El heroe es <x id="ICU"/></target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translate-select-1 -->
|
||||
<!-- #docregion translate-select-2 -->
|
||||
<trans-unit id="14c7055d67771a3b7b6888d282ac092896be06b6" datatype="html">
|
||||
<source/>
|
||||
<target>{gender, select, m {hombre} f {mujer}}</target>
|
||||
</trans-unit>
|
||||
<!-- #enddocregion translate-select-2 -->
|
||||
<!-- #enddocregion translated-select -->
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
6
aio/content/examples/i18n/src/main.1.ts
Normal file
6
aio/content/examples/i18n/src/main.1.ts
Normal file
@ -0,0 +1,6 @@
|
||||
// #docregion
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app/app.module';
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
10
aio/content/examples/i18n/src/main.ts
Normal file
10
aio/content/examples/i18n/src/main.ts
Normal file
@ -0,0 +1,10 @@
|
||||
// #docregion
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { getTranslationProviders } from './app/i18n-providers';
|
||||
|
||||
import { AppModule } from './app/app.module';
|
||||
|
||||
getTranslationProviders().then(providers => {
|
||||
const options = { providers };
|
||||
platformBrowserDynamic().bootstrapModule(AppModule, options);
|
||||
});
|
14
aio/content/examples/i18n/src/systemjs-text-plugin.js
Normal file
14
aio/content/examples/i18n/src/systemjs-text-plugin.js
Normal file
@ -0,0 +1,14 @@
|
||||
// #docregion
|
||||
/*
|
||||
SystemJS Text plugin from
|
||||
https://github.com/systemjs/plugin-text/blob/master/text.js
|
||||
*/
|
||||
exports.translate = function (load) {
|
||||
if (this.builder && this.transpiler) {
|
||||
load.metadata.format = 'esm';
|
||||
return 'exp' + 'ort var __useDefault = true; exp' + 'ort default ' + JSON.stringify(load.source) + ';';
|
||||
}
|
||||
|
||||
load.metadata.format = 'amd';
|
||||
return 'def' + 'ine(function() {\nreturn ' + JSON.stringify(load.source) + ';\n});';
|
||||
}
|
Reference in New Issue
Block a user