aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-ui/src/app/app.component.ts
diff options
context:
space:
mode:
authorLvbo163 <lv.bo163@zte.com.cn>2018-01-11 10:57:14 +0800
committerLvbo163 <lv.bo163@zte.com.cn>2018-01-11 10:57:14 +0800
commitc825e1c7a6fa1aa8f1c430384620ffd0addf25f8 (patch)
tree8ac8c13f7062d1907c7f82ca364a8a0d027f6efb /sdc-workflow-designer-ui/src/app/app.component.ts
parent008518dc35ded3bb6dc3e6352472b5816271f583 (diff)
add internationalization
add i18n for internationalization Issue-ID: SDC-901 Change-Id: I2784194b0fbf1f1b3de9dd03feb33d03ba495e15 Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-ui/src/app/app.component.ts')
-rw-r--r--sdc-workflow-designer-ui/src/app/app.component.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/sdc-workflow-designer-ui/src/app/app.component.ts b/sdc-workflow-designer-ui/src/app/app.component.ts
index ad61d636..4a58b5ef 100644
--- a/sdc-workflow-designer-ui/src/app/app.component.ts
+++ b/sdc-workflow-designer-ui/src/app/app.component.ts
@@ -16,6 +16,8 @@ import { WorkflowService } from "./services/workflow.service";
import { WorkflowNode } from "./model/workflow/workflow-node";
import { DataAccessService } from "./services/data-access/data-access.service";
import { ActivatedRoute } from "@angular/router";
+import { TranslateService } from '@ngx-translate/core';
+import { BroadcastService } from './services/broadcast.service';
@Component({
selector: 'app-root',
@@ -23,5 +25,28 @@ import { ActivatedRoute } from "@angular/router";
styleUrls: ['./app.component.css']
})
export class AppComponent {
+ public isLoading = true;
+ constructor(translate: TranslateService, private broadcastService: BroadcastService) {
+ // Init the I18n function.
+ // this language will be used as a fallback when a translation isn't found in the current language
+ translate.setDefaultLang('en');
+ // the lang to use, if the lang isn't available, it will use the current loader to get them
+ const topWin: any = window.top;
+ let browserLang = '';
+ if (topWin.getLanguage && typeof topWin.getLanguage == 'function') {
+ browserLang = topWin.getLanguage() || '';
+ } else {
+ // browserLang = translate.getBrowserCultureLang() || '';
+ // by default, window.navigator.languages will return a language list with the users prefered language as the first one.
+ // then, browserLang may with the result of translate.getBrowserCultureLang().
+ // but chrome version 57 not implement this functional. The first is not the user's prefered.
+ // So, browserLang can only use window.navigator.language as the user's prefered language.
+ browserLang = window.navigator.language;
+ }
+ translate.use(browserLang);
+ this.broadcastService.updateModelRestConfig$.subscribe(model=>{
+ this.isLoading = false;
+ });
+ }
}