Мне нужно кодировать метод или функцию в Angular, чтобы выбрать с раскрывающимся списком, какой язык я хочу отобразить.Но я закодировал выпадающий список и не знаю, как мне кодировать связь между выпадающим списком и файлом message.fr.xlf и отображать содержимое на экране после.Можете ли вы помочь мне, пожалуйста, я застрял на этом на 3 дня ....?Мой файл app.component.ts>> 1001 *
import { Component, LOCALE_ID, Inject } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
minutes = 0;
gender = 'female';
fly = true;
logo = 'https://angular.io/assets/images/logos/angular/angular.png';
heroes: string[] = ['Magneta', 'Celeritas', 'Dynama'];
public items: Array<string>;
inc(i: number) {
this.minutes = Math.min(5, Math.max(0, this.minutes + i));
}
male() { this.gender = 'male'; }
female() { this.gender = 'female'; }
other() { this.gender = 'other'; }
myFuncEnglish(lang) {
if (lang === 'EN') {
console.log('function called is english');
} else {
console.log('function called is french');
}
}
}
, а мой HTML-файл:
<h1 i18n="User welcome|An introduction header for this sample@@introductionHeader">
Hello i18n!
</h1>
<ng-container i18n>I don't output any element</ng-container>
<br />
<img [src]="logo" i18n-title title="Angular logo" />
<br>
<button (click)="inc(1)">+</button> <button (click)="inc(-1)">-</button>
<span i18n>Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}}</span>
({{minutes}})
<br><br>
<button (click)="male()">♂</button> <button (click)="female()">♀</button> <button (click)="other()">⚧</button>
<span i18n>The author is {gender, select, male {male} female {female} other {other}}</span>
<br><br>
<span i18n>Updated: {minutes, plural,
=0 {just now}
=1 {one minute ago}
other {{{minutes}} minutes ago by {gender, select, male {male} female {female} other {other}}}}
</span>
<select (ngModelChange)="myFuncEnglish($event)" [(ngModel)]="lang">
<option value="EN">English</option>
<option value="FR">France</option>
</select>