javascript - 角度 8 中的 AWS Amplify i18n 国际化
问题描述
翻译.ts
const dict = {
'bh': {
'Hello there!': "Apa khabar di sana!"
},
'ch': {
'Hello there!': "你好!"
}
};
I18n.putVocabularies(dict);
I18n.setLanguage('ch');
I18n.get('Hello there!');
翻译.html
<h3>(how to call function to get translation)</h3>
我正在尝试使用 AWS amplify i18n 功能翻译不同语言的网站文本。我正在关注 AWS-amplify 参考https://docs.amplify.aws/lib/utilities/i18n/q/platform/js#setlanguage
但我正在努力从 HTML 调用函数以用中文显示。
解决方案
您的“get”未分配给变量。尝试将 get 分配给变量并将其绑定到 UI。
this.text = I18n.get('Hello There');
然后在你的 HTML
<p>{{text}}</p>
推荐阅读
- java - 如何通过csv-spring读取队列而不是arrayList?
- c# - 实体框架 -FireBase- FileStream 文件无法访问
- spring-boot - 反应式 Spring Webflux 应用程序中的 Spring Cloud Stream Kafka Producer 事务性
- javascript - 异步调用 axios API 后使用 React hook 和 redux 的 SetState
- postgresql - PostgreSql 应用并行顺序扫描而不是索引扫描
- puppeteer - puppeteer:如何调用 action await page.goto(`${url}`); 在 .map((index, element) => {
- mediawiki - 媒体维基。基于模板/静态查询
- sql - 我有一个服务表,服务有价格,在新订单中我应该保存订单总额还是每次计算服务表
- angular - 检测具有相同名称但不同值的 Angular 绑定更改?
- c# - EntityFramework with service app fabric .net core stateless API SNI.dll not found 错误