简体   繁体   English

在 Angular 4+ 中使用 ngx-translate 进行本地化(国际化)?

[英]Localization (internationalization) in Angular 4+ using ngx-translate?

I am doing localization in Angular.我正在 Angular 中进行本地化。 I am not sure how to do localization for async observables.我不确定如何对异步 observables 进行本地化。

Here I do it in for regular html without using async.在这里,我在不使用异步的情况下为常规 html 执行此操作。

<p class="pageTwo" [translate]="'users.licenses'">
  Licenses purchased
</p>

I am not sure how to implement the ngx-translate library for async pipe.我不确定如何为异步 pipe 实现 ngx-translate 库。

<p class="availablelicenses">
  {{ numberOfLicensed$ | async }}
</p>

Here is the solution:这是解决方案:

<p class="availablelicenses" [translate]="'usersPage.numberLicense'" [translateParams]="{number: numberOfLicensed$ | async}"></p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM