[英]Angular 5 i18n Pipe Directive Use?
我有一個i18n管道,我無法弄清楚如何在模板中翻譯數組項目。
這是模板組件:
import {Component, OnInit, Input} from '@angular/core';
@Component({
selector: 'sa-big-breadcrumbs',
template: `
<div><h1 class="page-title txt-color-blueDark">
<i class="fa-fw fa fa-{{icon}}"></i>{{items[0]}}
<span *ngFor="let item of items.slice(1)">> {{item}} </span>
</h1></div>
`,
})
export class BigBreadcrumbsComponent implements OnInit {
@Input() public icon: string;
@Input() public items: Array<string>;
constructor() {}
ngOnInit() {
}
}
這是使用選擇器的HTML:
<div class="row">
<sa-big-breadcrumbs [items]="['Forum General View']" icon="comment" class="col-xs-12 col-sm-7 col-md-7 col-lg-4"></sa-big-breadcrumbs>
<sa-stats></sa-stats>
</div>
我想翻譯模板中的“論壇一般視圖”
{{items[0]}}
我在簡單的字符串翻譯中使用管道沒有問題,但是翻譯數組項目並不是我能夠解決的問題。
通常,我的翻譯看起來像這樣:
<a href="#"><i class="fa fa-lg fa-fw fa-comments"></i> {{'Forum' | i18n}}</a>
謝謝你的幫助!
短發
我是OP。 事實證明,i18n管道工作正常。 問題是由於翻譯服務沒有持久的語言。 一旦我修復了持久性,那么管道就可以在我需要的任何地方工作。
短發
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.