繁体   English   中英

angular 8 中的 AWS Amplify i18n 国际化

[英]AWS Amplify i18n internationalization in angular 8

翻译.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 调用 function 以中文显示。

您的“get”未分配给变量。 尝试将 get 分配给变量并将其绑定到 UI。

this.text = I18n.get('Hello There');

然后在你的 HTML

<p>{{text}}</p>

暂无
暂无

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

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