angular-cn/aio/content/examples/cb-i18n/ts/plnkr.no-link.html

329 lines
10 KiB
HTML

<html lang="en"><head></head><body><form id="mainForm" method="post" action="http://plnkr.co/edit/?p=preview" target="_self"><input type="hidden" name="files[app/app.component.html]" value="<h1 i18n=&quot;User welcome|An introduction header for this sample&quot;>Hello i18n!</h1>
<ng-container i18n>I don't output any element</ng-container>
<br />
<!--i18n: optional meaning|optional description -->
I don't output any element either
<!--/i18n-->
<br />
<img [src]=&quot;logo&quot; i18n-title title=&quot;Angular logo&quot; />
<br>
<button (click)=&quot;inc(1)&quot;>+</button> <button (click)=&quot;inc(-1)&quot;>-</button>
<span i18n>{wolves, plural, =0 {no wolves} =1 {one wolf} =2 {two wolves} other {a wolf pack}}</span>
({{wolves}})
<br><br>
<button (click)=&quot;male()&quot;>&amp;#9794;</button> <button (click)=&quot;female()&quot;>&amp;#9792;</button>
<span i18n>The hero is {gender, select, m {male} f {female}}</span>
<br>
<!--
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
-->"><input type="hidden" name="files[app/app.component.ts]" value="import { Component } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'my-app',
templateUrl: './app.component.html'
})
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'; }
}
/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/"><input type="hidden" name="files[app/app.module.ts]" value="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 { }
/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/"><input type="hidden" name="files[app/i18n-providers.ts]" value="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
}
/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/"><input type="hidden" name="files[locale/messages.es.xlf]" value="<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?>
<xliff version=&quot;1.2&quot; xmlns=&quot;urn:oasis:names:tc:xliff:document:1.2&quot;>
<file source-language=&quot;en&quot; datatype=&quot;plaintext&quot; original=&quot;ng2.template&quot;>
<body>
<trans-unit id=&quot;af2ccf4b5dba59616e92cf1531505af02da8f6d2&quot; datatype=&quot;html&quot;>
<source>Hello i18n!</source>
<target>¡Hola i18n!</target>
<note priority=&quot;1&quot; from=&quot;description&quot;>An introduction header for this sample</note>
<note priority=&quot;1&quot; from=&quot;meaning&quot;>User welcome</note>
</trans-unit>
<trans-unit id=&quot;ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3&quot; datatype=&quot;html&quot;>
<source>I don&amp;apos;t output any element</source>
<target>No genero ningún elemento</target>
</trans-unit>
<trans-unit id=&quot;df3cf8b55cb528cf8c00167e0b119bfb828538b5&quot; datatype=&quot;html&quot;>
<source>
I don&amp;apos;t output any element either
</source>
<target>Yo tampoco genero ningún elemento</target>
<note priority=&quot;1&quot; from=&quot;description&quot;>optional description</note>
<note priority=&quot;1&quot; from=&quot;meaning&quot;>optional meaning</note>
</trans-unit>
<trans-unit id=&quot;701174153757adf13e7c24a248c8a873ac9f5193&quot; datatype=&quot;html&quot;>
<source>Angular logo</source>
<target>Logo de Angular</target>
</trans-unit>
<trans-unit id=&quot;6e22e74e8cbd3095560cfe08993c4fdfa3c50eb0&quot; datatype=&quot;html&quot;>
<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=&quot;61cafedb85466ab789b3ae817bba1a545468ee1c&quot; datatype=&quot;html&quot;>
<source>The hero is <x id=&quot;ICU&quot;/></source>
<target>El heroe es <x id=&quot;ICU&quot;/></target>
</trans-unit>
<trans-unit id=&quot;14c7055d67771a3b7b6888d282ac092896be06b6&quot; datatype=&quot;html&quot;>
<source/>
<target>{gender, select, m {hombre} f {mujer}}</target>
</trans-unit>
</body>
</file>
</xliff>
"><input type="hidden" name="files[styles.css]" value="/* Master Styles */
h1 {
color: #369;
font-family: Arial, Helvetica, sans-serif;
font-size: 250%;
}
h2, h3 {
color: #444;
font-family: Arial, Helvetica, sans-serif;
font-weight: lighter;
}
body {
margin: 2em;
}
body, input[text], button {
color: #888;
font-family: Cambria, Georgia;
}
a {
cursor: pointer;
cursor: hand;
}
button {
font-family: Arial;
background-color: #eee;
border: none;
padding: 5px 10px;
border-radius: 4px;
cursor: pointer;
cursor: hand;
}
button:hover {
background-color: #cfd8dc;
}
button:disabled {
background-color: #eee;
color: #aaa;
cursor: auto;
}
/* Navigation link styles */
nav a {
padding: 5px 10px;
text-decoration: none;
margin-right: 10px;
margin-top: 10px;
display: inline-block;
background-color: #eee;
border-radius: 4px;
}
nav a:visited, a:link {
color: #607D8B;
}
nav a:hover {
color: #039be5;
background-color: #CFD8DC;
}
nav a.active {
color: #039be5;
}
/* items class */
.items {
margin: 0 0 2em 0;
list-style-type: none;
padding: 0;
width: 24em;
}
.items li {
cursor: pointer;
position: relative;
left: 0;
background-color: #EEE;
margin: .5em;
padding: .3em 0;
height: 1.6em;
border-radius: 4px;
}
.items li:hover {
color: #607D8B;
background-color: #DDD;
left: .1em;
}
.items li.selected {
background-color: #CFD8DC;
color: white;
}
.items li.selected:hover {
background-color: #BBD8DC;
}
.items .text {
position: relative;
top: -3px;
}
.items .badge {
display: inline-block;
font-size: small;
color: white;
padding: 0.8em 0.7em 0 0.7em;
background-color: #607D8B;
line-height: 1em;
position: relative;
left: -1px;
top: -4px;
height: 1.8em;
margin-right: .8em;
border-radius: 4px 0 0 4px;
}
/* everywhere else */
* {
font-family: Arial, Helvetica, sans-serif;
}
/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/"><input type="hidden" name="files[systemjs-text-plugin.js]" value="/*
SystemJS Text plugin from
https://github.com/systemjs/plugin-text/blob/master/text.js
*/
exports.translate = function(load) {
if (this.builder &amp;&amp; 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});';
}
/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/"><input type="hidden" name="files[index.html]" value="<!DOCTYPE html>
<html>
<head>
<title>Angular i18n example</title>
<script>document.write('<base href=&quot;' + document.location + '&quot; />');</script>
<meta charset=&quot;UTF-8&quot;>
<meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;>
<link rel=&quot;stylesheet&quot; href=&quot;styles.css&quot;>
<script src=&quot;https://unpkg.com/core-js/client/shim.min.js&quot;></script>
<script src=&quot;https://unpkg.com/zone.js@0.7.4?main=browser&quot;></script>
<script src=&quot;https://unpkg.com/systemjs@0.19.39/dist/system.src.js&quot;></script>
<script src=&quot;https://cdn.rawgit.com/angular/angular.io/b3c65a9/public/docs/_examples/_boilerplate/systemjs.config.web.js&quot;></script>
<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>
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
<!--
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
-->"><input type="hidden" name="tags[0]" value="angular"><input type="hidden" name="tags[1]" value="example"><input type="hidden" name="tags[2]" value="i18n"><input type="hidden" name="private" value="true"><input type="hidden" name="description" value="Angular Example - i18n"></form><script>document.getElementById("mainForm").submit();</script></body></html>