AWS 在 angular 8 中放大 i18n 国际化



translate.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 放大参考 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>

最新更新