Skip to content

Commit d8a5472

Browse files
authored
Merge branch 'international' into master
2 parents 3f762f0 + 89f4071 commit d8a5472

18 files changed

+252
-99
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ is recommended only have one ``<dual-list>`` visable to the user at a time.
7474
## Contributions
7575

7676
Contributions may be welcomed depending on impact on the core functionality of the project. In order for pull requests to be accepted, they must include a sign-off in git (See [git-commit
77-
--signoff](https://git-scm.com/docs/git-commit)) certifying the contribution is your own work, are subitting under the projects original license, and agreeing to the [Developer Certificate of
77+
--signoff](https://git-scm.com/docs/git-commit)) certifying the contribution is your own work, are subitting under the project's original license, and agreeing to the [Developer Certificate of
7878
Origin](https://developercertificate.org/).
7979

8080
## License

app/demo-app.component.ts

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { Component, OnInit } from '@angular/core';
55
template: `
66
<div class="container-fluid">
77
<p></p>
8-
<dual-list [sort]="keepSorted" [source]="source" [key]="key" [display]="display" [filter]="filter" [(destination)]="confirmed" height="265px"></dual-list>
8+
<dual-list [sort]="keepSorted" [source]="source" [key]="key" [display]="display" [filter]="filter"
9+
[(destination)]="confirmed" height="265px"></dual-list>
910
1011
<ul class="nav nav-tabs" style="margin-top:50px;">
1112
<li [class.active]="tab===1"><a (click)="tab=1">Arrays</a><li>
@@ -42,6 +43,12 @@ import { Component, OnInit } from '@angular/core';
4243
<div class="col-sm-12">
4344
<label>General</label><br/>
4445
<form class="form-inline well">
46+
<div class="btn-group">
47+
<button type="button" class="btn btn-default dropdown-toggle" (click)="setLangMenu()">Select Language <span class="caret"></span></button>
48+
<ul class="dropdown-menu" [ngStyle]="{ display: langMenu }">
49+
<li *ngFor="let l of languages"><a (click)="setLanguage(l.code)" style="user-select:none">{{l.name}}</a></li>
50+
</ul>
51+
</div>
4552
<button class="btn btn-default" (click)="doFilter()">{{filterBtn()}}</button>
4653
<button class="btn btn-default" (click)="doSwap()">Swap source</button>
4754
<button class="btn btn-primary" (click)="doReset()">Reset</button>
@@ -53,9 +60,16 @@ import { Component, OnInit } from '@angular/core';
5360
`
5461
})
5562

56-
export class DemoAppComponent implements OnInit{
63+
export class DemoAppComponent implements OnInit {
5764

5865
tab = 1;
66+
langMenu = 'none';
67+
languages = [
68+
{ name: 'English', code: 'en-US' },
69+
{ name: 'French', code: 'fr' },
70+
{ name: 'Spanish', code: 'es' }
71+
];
72+
5973
keepSorted = true;
6074
key:string;
6175
display:string;
@@ -105,15 +119,15 @@ export class DemoAppComponent implements OnInit{
105119
{ key: 30, station: 'Elk Park', state: 'CO' },
106120
{ key: 31, station: 'Silverton', state: 'CO' },
107121
{ key: 32, station: 'Eureka', state: 'CO' }
108-
];
122+
];
109123

110124
private chessmen:Array<any> = [
111-
{ _id: 1, name: "Pawn" },
112-
{ _id: 2, name: "Rook" },
113-
{ _id: 3, name: "Knight" },
114-
{ _id: 4, name: "Bishop" },
115-
{ _id: 5, name: "Queen" },
116-
{ _id: 6, name: "King" }
125+
{ _id: 1, name: 'Pawn' },
126+
{ _id: 2, name: 'Rook' },
127+
{ _id: 3, name: 'Knight' },
128+
{ _id: 4, name: 'Bishop' },
129+
{ _id: 5, name: 'Queen' },
130+
{ _id: 6, name: 'King' }
117131
];
118132

119133
ngOnInit() {
@@ -125,7 +139,7 @@ export class DemoAppComponent implements OnInit{
125139
this.key = 'key';
126140
this.display = 'station';
127141
this.keepSorted = true;
128-
this.source = this.sourceStations;;
142+
this.source = this.sourceStations;
129143
this.confirmed = this.confirmedStations;
130144
}
131145

@@ -199,4 +213,20 @@ export class DemoAppComponent implements OnInit{
199213
return (this.filter ? 'Hide Filter' : 'Show Filter');
200214
}
201215

216+
setLangMenu() {
217+
if (this.langMenu === 'none') {
218+
this.langMenu = 'inherit';
219+
} else {
220+
this.langMenu = 'none';
221+
}
222+
}
223+
224+
// http://stackoverflow.com/a/40363782
225+
setLanguage(language:string) {
226+
localStorage.setItem('localeId', language);
227+
location.reload(true);
228+
return false;
229+
}
230+
231+
202232
}

app/i18n-providers.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID } from '@angular/core';
2+
3+
export function getTranslationProviders(): Promise<Object[]> {
4+
5+
// Get the locale id from the global
6+
// const locale = document['locale'] as string;
7+
let locale = localStorage.getItem('localeId');
8+
9+
// return no providers if fail to get translation file for locale
10+
const noProviders: Object[] = [];
11+
12+
// No locale or U.S. English: no translation providers
13+
if (!locale || locale === 'en-US') {
14+
return Promise.resolve(noProviders);
15+
}
16+
17+
// Ex: 'locale/messages.es.xlf`
18+
const translationFile = `./locale/messages.${locale}.xlf`;
19+
20+
return getTranslationsWithSystemJs(translationFile)
21+
.then( (translations: string ) => [
22+
{ provide: TRANSLATIONS, useValue: translations },
23+
{ provide: TRANSLATIONS_FORMAT, useValue: 'xlf' },
24+
{ provide: LOCALE_ID, useValue: locale }
25+
])
26+
.catch(() => noProviders); // ignore if file not found
27+
}
28+
29+
declare var System: any;
30+
31+
function getTranslationsWithSystemJs(file: string) {
32+
return System.import(file + '!text'); // relies on text plugin
33+
}
34+

app/main.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
22
import { enableProdMode } from '@angular/core';
3+
import { getTranslationProviders } from './i18n-providers';
34

45
import { AppModule } from './app.module';
56

67
const platform = platformBrowserDynamic();
78

89
enableProdMode();
910

10-
platform.bootstrapModule( AppModule );
11+
// platform.bootstrapModule( AppModule );
12+
13+
getTranslationProviders().then(providers => {
14+
const options = { providers };
15+
platform.bootstrapModule( AppModule, options);
16+
});
1117

1218

demo/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
<script src="demo/systemjs.config.js"></script>
2222
<script>
23+
System.config({map:{text:'systemjs-text-plugin.js'}});
2324
System.import('app').catch(function(err){ console.error(err); });
2425
</script>
2526
</head>

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
<script src="systemjs.config.js"></script>
2727
<script>
28+
System.config({map:{text:'systemjs-text-plugin.js'}});
2829
System.import('app').catch(function(err){ console.error(err); });
2930
</script>
3031
</head>

lib/dual-list.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="listbox">
33
<button type="button" name="addBtn" class="btn btn-primary btn-block"
44
(click)="moveItem(available, confirmed)"
5-
[disabled]="available.pick.length === 0">Add</button>
5+
[disabled]="available.pick.length === 0"><span i18n="add button|Add to confirmed list.">Add</span></button>
66

77
<form *ngIf="filter" class="filter">
88
<input class="form-control" name="filterSource" [(ngModel)]="available.picker" (ngModelChange)="onFilter(available)">
@@ -21,16 +21,16 @@
2121

2222
<div class="button-bar">
2323
<button type="button" class="btn btn-primary pull-left" (click)="selectAll(available)"
24-
[disabled]="isAllSelected(available)">All</button>
24+
[disabled]="isAllSelected(available)"><span i18n="all button|Select all in list.">All</span></button>
2525
<button type="button" class="btn btn-default pull-right" (click)="selectNone(available)"
26-
[disabled]="!isAnySelected(available)">None</button>
26+
[disabled]="!isAnySelected(available)"><span i18n="none button|Deselect all in list.">None</span></button>
2727
</div>
2828
</div>
2929

3030
<div class="listbox" style="margin-left:10px;">
3131
<button type="button" name="removeBtn" class="btn btn-primary btn-block"
3232
(click)="moveItem(confirmed, available)"
33-
[disabled]="confirmed.pick.length === 0">Remove</button>
33+
[disabled]="confirmed.pick.length === 0"><span i18n="remove button|Remove from confirimed list.">Remove</span></button>
3434

3535
<form *ngIf="filter" class="filter">
3636
<input class="form-control" name="filterDestination" [(ngModel)]="confirmed.picker" (ngModelChange)="onFilter(confirmed)">
@@ -49,9 +49,9 @@
4949

5050
<div class="button-bar">
5151
<button type="button" class="btn btn-primary pull-left" (click)="selectAll(confirmed)"
52-
[disabled]="isAllSelected(confirmed)">All</button>
52+
[disabled]="isAllSelected(confirmed)"><span i18n="all button|Select all in list.">All</span></button>
5353
<button type="button" class="btn btn-default pull-right" (click)="selectNone(confirmed)"
54-
[disabled]="!isAnySelected(confirmed)">None</button>
54+
[disabled]="!isAnySelected(confirmed)"><span i18n="none button|Deselect all in list.">None</span></button>
5555
</div>
5656
</div>
5757
</div>

locale/messages.es.xlf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="ng2.template">
4+
<body>
5+
<trans-unit id="87f79aff82a5232d109e41d56aef22888726b4d1" datatype="html">
6+
<source>Add</source>
7+
<target>Añadir</target>
8+
<note priority="1" from="description">Add to confirmed list.</note>
9+
<note priority="1" from="meaning">add button</note>
10+
</trans-unit>
11+
<trans-unit id="0549d8dbf6b6a3f772e095a3e6efa556fb62d388" datatype="html">
12+
<source>All</source>>
13+
<target>Todas</target>
14+
<note priority="1" from="description">Select all in list.</note>
15+
<note priority="1" from="meaning">all button</note>
16+
</trans-unit>
17+
<trans-unit id="f255a8f80d2dbe8a191b8bb7a8e334f3a489f6a2" datatype="html">
18+
<source>None</source>
19+
<target>Nada</target>
20+
<note priority="1" from="description">Deselect all in list.</note>
21+
<note priority="1" from="meaning">none button</note>
22+
</trans-unit>
23+
<trans-unit id="8584bddcbc06daed5b2c452bd39d036f9c7cfdb0" datatype="html">
24+
<source>Remove</source>
25+
<target>Eliminar</target>
26+
<note priority="1" from="description">Remove from confirimed list.</note>
27+
<note priority="1" from="meaning">remove button</note>
28+
</trans-unit>
29+
</body>
30+
</file>
31+
</xliff>

locale/messages.fr.xlf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="ng2.template">
4+
<body>
5+
<trans-unit id="87f79aff82a5232d109e41d56aef22888726b4d1" datatype="html">
6+
<source>Add</source>
7+
<target>Ajouter</target>
8+
<note priority="1" from="description">Add to confirmed list.</note>
9+
<note priority="1" from="meaning">add button</note>
10+
</trans-unit>
11+
<trans-unit id="0549d8dbf6b6a3f772e095a3e6efa556fb62d388" datatype="html">
12+
<source>All</source>>
13+
<target>Tout</target>
14+
<note priority="1" from="description">Select all in list.</note>
15+
<note priority="1" from="meaning">all button</note>
16+
</trans-unit>
17+
<trans-unit id="f255a8f80d2dbe8a191b8bb7a8e334f3a489f6a2" datatype="html">
18+
<source>None</source>
19+
<target>Aucun</target>
20+
<note priority="1" from="description">Deselect all in list.</note>
21+
<note priority="1" from="meaning">none button</note>
22+
</trans-unit>
23+
<trans-unit id="8584bddcbc06daed5b2c452bd39d036f9c7cfdb0" datatype="html">
24+
<source>Remove</source>
25+
<target>Retirer</target>
26+
<note priority="1" from="description">Remove from confirimed list.</note>
27+
<note priority="1" from="meaning">remove button</note>
28+
</trans-unit>
29+
</body>
30+
</file>
31+
</xliff>

locale/messages.xlf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="ng2.template">
4+
<body>
5+
<trans-unit id="87f79aff82a5232d109e41d56aef22888726b4d1" datatype="html">
6+
<source>Add</source>
7+
<target/>
8+
<note priority="1" from="description">Add to confirmed list.</note>
9+
<note priority="1" from="meaning">add button</note>
10+
</trans-unit>
11+
<trans-unit id="0549d8dbf6b6a3f772e095a3e6efa556fb62d388" datatype="html">
12+
<source>All</source>
13+
<target/>
14+
<note priority="1" from="description">Select all in list.</note>
15+
<note priority="1" from="meaning">all button</note>
16+
</trans-unit>
17+
<trans-unit id="f255a8f80d2dbe8a191b8bb7a8e334f3a489f6a2" datatype="html">
18+
<source>None</source>
19+
<target/>
20+
<note priority="1" from="description">Deselect all in list.</note>
21+
<note priority="1" from="meaning">none button</note>
22+
</trans-unit>
23+
<trans-unit id="8584bddcbc06daed5b2c452bd39d036f9c7cfdb0" datatype="html">
24+
<source>Remove</source>
25+
<target/>
26+
<note priority="1" from="description">Remove from confirimed list.</note>
27+
<note priority="1" from="meaning">remove button</note>
28+
</trans-unit>
29+
</body>
30+
</file>
31+
</xliff>

0 commit comments

Comments
 (0)