Angular 9:TypeScript中的i18n [英] Angular 9: i18n in TypeScript
本文介绍了Angular 9:TypeScript中的i18n的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我研究了Angular 9中的新i18n功能. https://angular.io/guide/i18n
I studied the new i18n feature in Angular 9. https://angular.io/guide/i18n
如何在TypeScript中翻译文本,例如SnackBar消息?
How to translate text in TypeScript, e.g. SnackBar messages?
推荐答案
检查此博客 https://blog.ninja-squad.com/2019/12/10/angular-localize/
@Component({
template: '{{ title }}'
})
export class HomeComponent {
title = $localize`You have 10 users`;
}
还有
您必须手动将其添加到您的messages.fr.xlf
You have to manually add it to your messages.fr.xlf
<trans-unit id="6480943972743237078">
<source>You have 10 users</source>
<target>Vous avez 10 utilisateurs</target>
</trans-unit>
别忘了为您的角度应用服务.
don't forgot re serve your angular application.
更新ID
@Component({
template: '{{ title }}'
})
export class HomeComponent {
title = $localize`:@@6480943972743237078:`;
}
这篇关于Angular 9:TypeScript中的i18n的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文