简体   繁体   English

angular 8 中的 AWS Amplify i18n 国际化

[英]AWS Amplify i18n internationalization in angular 8

translate.ts翻译.ts

const dict = {
   'bh': {
      'Hello there!': "Apa khabar di sana!"   
  },
  'ch': {
      'Hello there!': "你好!"
  }
};

I18n.putVocabularies(dict);
I18n.setLanguage('ch');
I18n.get('Hello there!');

translate.html翻译.html

<h3>(how to call function to get translation)</h3>

I am trying to translate website texts in different languages using AWS amplify i18n feature.我正在尝试使用 AWS amplify i18n 功能翻译不同语言的网站文本。 I am following AWS-amplify reference https://docs.amplify.aws/lib/utilities/i18n/q/platform/js#setlanguage我正在关注 AWS-amplify 参考https://docs.amplify.aws/lib/utilities/i18n/q/platform/js#setlanguage

But I am struggling with calling function from HTML to show in Chinese language.但我正在努力从 HTML 调用 function 以中文显示。

Your "get" isn't assigned to a variable.您的“get”未分配给变量。 Try assigning the get to a variable and bind it to the UI.尝试将 get 分配给变量并将其绑定到 UI。

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

Then in your HTML然后在你的 HTML

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

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

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