template 引用 i18n
透過用 pipe
1
| <p>{{ 'global.dialog.blacklist.title' | translate }}</p>
|
透過 js 直接翻譯
1
| this.translate.instant("global.dialog.blacklist.title");
|
比較不推薦的寫法
1
| <element [translate]="'id'"></element> <element translate>id</element>
|
translate parameters
1 2 3 4 5 6 7
| { "demo": { "title": "Translation demo", "text": "This is a simple demonstration app for ngx-translate", "greeting": "Hello {{name}}!" } }
|
1
| console.log(translate.instant('demo.greeting', {name: 'John'}));
|
1 2
| <p>{{ 'demo.greeting' | translate : {name: 'John'} }}</p> <li [translate]="'demo.greeting'" [translateParams]="{name: 'John'}"></li>
|