angular - Angular 9:TypeScript 中的 i18n
解决方案
检查此博客https://blog.ninja-squad.com/2019/12/10/angular-localize/
来自官方文档:https ://angular.io/api/localize/init/$localize
@Component({
template: '{{ title }}'
})
export class HomeComponent {
title = $localize`You have 10 users`;
}
和
您必须手动将其添加到您的 messages.fr.xlf
<trans-unit id="6480943972743237078">
<source>You have 10 users</source>
<target>Vous avez 10 utilisateurs</target>
</trans-unit>
不要忘记重新服务您的角度应用程序。
更新ID
@Component({
template: '{{ title }}'
})
export class HomeComponent {
title = $localize`:@@6480943972743237078:`;
}
推荐阅读
- android - 使用 Kotlin 获取 Android 应用程序列表
- javascript - Sortablejs根据与边缘的距离自动滚动速度
- csv - 如何在颤动中显示或加载 CSV 文件中的数据到列表中
- android - Android Studio 关于已弃用 API 的警告
- javascript - 如何避免警告:无法在未安装的组件上设置状态?反应原生
- python - 为什么我的 try-exception-finally 无法正常工作
- angular - Angular 8/9 如何以编程方式将焦点设置在 MatInput 上
- pandas - Teradata 插入错误:ValueError:DataFrame 的真值不明确
- javascript - 使用 Moment 使用 Electron/NodeJS 将标准时间格式化为 ISO 8601
- c - 如何使用 int** 在 C 中传递二维数组