aboutsummaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/app.component.ts
blob: be13c1a1aaffaa483cde67fcd9f429319de1d863 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Component } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.less']
})
export class AppComponent {
  constructor(private translate:TranslateService){
    translate.addLangs(['en', 'zh']);
    translate.setDefaultLang('en');
    // translate.use('en');
  }
  changeLanguage(Language): void {
    switch(Language){
      case 'en':
        this.translate.use('en');
        break;
      case 'zh':
        this.translate.use('zh');
    }
  }
  // 多语言
  Language:String[] = ["zh","en"];
  selectLanguage = "en";
  changeLanguage1(){
    this.translate.use(this.selectLanguage);
  }
  changeLanguage2(item){
    this.translate.use(item);
  }
}