From a24c8d3ac324393ca1ecacbcd42e751f6dff6cd5 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Fri, 5 Oct 2018 13:01:51 +0200 Subject: [PATCH] Add flag dropdown for language selection --- static/src/app/app.component.html | 27 ++++++++++------------- static/src/app/app.component.ts | 18 +++++++++++---- static/src/app/app.module.ts | 3 ++- static/src/assets/i18n/app/en.json | 4 ++-- static/src/assets/i18n/statistics/en.json | 2 +- static/src/assets/icon/locale/de.svg | 5 +++++ static/src/assets/icon/locale/gb.svg | 15 +++++++++++++ 7 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 static/src/assets/icon/locale/de.svg create mode 100644 static/src/assets/icon/locale/gb.svg diff --git a/static/src/app/app.component.html b/static/src/app/app.component.html index 4b302d2..4021bad 100644 --- a/static/src/app/app.component.html +++ b/static/src/app/app.component.html @@ -89,21 +89,6 @@ diff --git a/static/src/app/app.component.ts b/static/src/app/app.component.ts index 6ee0f32..e9155cc 100644 --- a/static/src/app/app.component.ts +++ b/static/src/app/app.component.ts @@ -6,7 +6,7 @@ import {AwardingService} from './services/army-management/awarding.service'; import {RouteConfig} from './app.config'; import {DOCUMENT} from '@angular/common'; import {DomSanitizer} from '@angular/platform-browser'; -import {MatIconRegistry} from '@angular/material'; +import {MatIconRegistry, MatSelectChange} from '@angular/material'; import {SpinnerService} from './services/user-interface/spinner/spinner.service'; import {TranslateService} from '@ngx-translate/core'; import {SettingsService} from './services/settings.service'; @@ -55,8 +55,15 @@ export class AppComponent implements OnInit { 'vehicleAir': 'stats/scoreboard/vehicleAir', 'vehicleHeavy': 'stats/scoreboard/vehicleHeavy', 'vehicleLight': 'stats/scoreboard/vehicleLight', + // --------LOCALE--------- + 'flag-de': 'locale/de', + 'flag-gb': 'locale/gb', }; + language; + + languages = ['de', 'en']; + version = 'v'.concat(require('./../../../package.json').version); constructor(public loginService: LoginService, @@ -90,7 +97,10 @@ export class AppComponent implements OnInit { } ngOnInit() { - this.settingsService.getLanguage().subscribe((language) => this.translate.setDefaultLang(language)); + this.settingsService.getLanguage().subscribe((language) => { + this.language = language; + this.translate.setDefaultLang(language) + }); if (this.loginService.hasPermission(2)) { const fraction = this.loginService.getCurrentUser().squad.fraction; this.promotionService.checkUnconfirmedPromotions(fraction); @@ -104,8 +114,7 @@ export class AppComponent implements OnInit { initMaterialSvgIcons() { Object.keys(this.svgIcons).forEach(key => { - const fileUri = '../assets/icon/'.concat(this.svgIcons[key]) - .concat('.svg'); + const fileUri = '../assets/icon/'.concat(this.svgIcons[key]).concat('.svg'); this.iconRegistry.addSvgIcon(key, this.sanitizer.bypassSecurityTrustResourceUrl(fileUri)); }); } @@ -130,6 +139,7 @@ export class AppComponent implements OnInit { setLanguage(language: string) { if (language) { + this.language = language; this.settingsService.setLanguage(language); } } diff --git a/static/src/app/app.module.ts b/static/src/app/app.module.ts index b644e68..f4f295c 100644 --- a/static/src/app/app.module.ts +++ b/static/src/app/app.module.ts @@ -24,7 +24,7 @@ import {CookieService} from 'ngx-cookie-service'; import {SnackBarService} from './services/user-interface/snack-bar/snack-bar.service'; import {HttpClientModule} from '@angular/common/http'; import {SpinnerService} from './services/user-interface/spinner/spinner.service'; -import {MatSnackBarModule} from '@angular/material'; +import {MatSelectModule, MatSnackBarModule} from '@angular/material'; import {HttpClient} from './services/http-client'; import {SettingsService} from './services/settings.service'; @@ -38,6 +38,7 @@ import {SettingsService} from './services/settings.service'; HttpClientModule, ClipboardModule, MatSnackBarModule, + MatSelectModule, ], providers: [ diff --git a/static/src/assets/i18n/app/en.json b/static/src/assets/i18n/app/en.json index 21032d4..b91a502 100644 --- a/static/src/assets/i18n/app/en.json +++ b/static/src/assets/i18n/app/en.json @@ -7,10 +7,10 @@ "public.error.message.default": "{{fieldName}} is not valid", "public.common.search.button": "Search", - "navigation.top.board": "To message board", + "navigation.top.board": "To Message Board", "navigation.top.overview": "Army Overview", "navigation.top.ranks": "Ranks", - "navigation.top.decorations": "Awards", + "navigation.top.decorations": "Decorations", "navigation.top.statistics": "Statistics", "navigation.top.login": "Login", "navigation.top.logout": "Logout", diff --git a/static/src/assets/i18n/statistics/en.json b/static/src/assets/i18n/statistics/en.json index 8b37afe..f412529 100644 --- a/static/src/assets/i18n/statistics/en.json +++ b/static/src/assets/i18n/statistics/en.json @@ -17,7 +17,7 @@ "stats.sidebar.overview": "Overview", "stats.sidebar.highscore": "Highscore", "stats.sidebar.battles": "Battles", - "stats.sidebar.battles.battle.from.date": "at", + "stats.sidebar.battles.battle.from.date": "of", "stats.sidebar.battle.manage.edit": "Edit", "stats.sidebar.battle.manage.delete": "Delete", "stats.sidebar.battle.manage.delete.confirm": "Do you really want to delete the battle \"{{title}}\"?", diff --git a/static/src/assets/icon/locale/de.svg b/static/src/assets/icon/locale/de.svg new file mode 100644 index 0000000..4b12641 --- /dev/null +++ b/static/src/assets/icon/locale/de.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/static/src/assets/icon/locale/gb.svg b/static/src/assets/icon/locale/gb.svg new file mode 100644 index 0000000..64d1a1c --- /dev/null +++ b/static/src/assets/icon/locale/gb.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + +