329 lines
10 KiB
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="User welcome|An introduction header for this sample">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]="logo" i18n-title title="Angular logo" />
|
|
<br>
|
|
<button (click)="inc(1)">+</button> <button (click)="inc(-1)">-</button>
|
|
<span i18n>{wolves, plural, =0 {no wolves} =1 {one wolf} =2 {two wolves} other {a wolf pack}}</span>
|
|
({{wolves}})
|
|
<br><br>
|
|
<button (click)="male()">&#9794;</button> <button (click)="female()">&#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="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&apos;t output any element</source>
|
|
<target>No genero ningún elemento</target>
|
|
</trans-unit>
|
|
<trans-unit id="df3cf8b55cb528cf8c00167e0b119bfb828538b5" datatype="html">
|
|
<source>
|
|
I don&apos;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>
|
|
"><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 && 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="' + document.location + '" />');</script>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" href="styles.css">
|
|
|
|
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
|
|
|
|
<script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
|
|
<script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
|
|
|
|
<script src="https://cdn.rawgit.com/angular/angular.io/b3c65a9/public/docs/_examples/_boilerplate/systemjs.config.web.js"></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> |