Update the copyright info
[holmes/rule-management.git] / rulemgt-frontend / src / app / app.component.ts
1 /*
2  Copyright 2018-2021 ZTE Corporation.
3
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7
8      http://www.apache.org/licenses/LICENSE-2.0
9
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 import { Component, OnInit } from '@angular/core';
17 import { TranslateService } from '@ngx-translate/core';
18
19 @Component({
20     selector: 'remote-config',
21     templateUrl: './pages/remote.component.html'
22 })
23 export class AppComponent implements OnInit {
24     constructor(private translate: TranslateService) { }
25     getLanguage(): string {
26         let rtnLanguage = localStorage.getItem('language-option');
27         if (rtnLanguage == 'null' || rtnLanguage == null) {
28             rtnLanguage = window.navigator.language;
29         }
30         if (rtnLanguage.startsWith('zh')) {
31             return 'zh';
32         } else {
33             return 'en';
34         }
35     }
36
37     ngOnInit(): void {
38         this.translate.addLangs(['en', 'zh']);
39         this.translate.setDefaultLang('en');
40         let language = this.getLanguage();
41         this.translate.use(language);
42     }
43 }