【问题标题】:Is there a way to translate dynamic content used as interpolation - Internationalization i18n?有没有办法翻译用作插值的动态内容 - Internationalization i18n?
【发布时间】:2017-12-05 14:15:01
【问题描述】:

我正在为应用程序使用 i18n 国际化,并且在某些组件中确实有动态消息和文本,它们通过interpolation 动态嵌入到 HTML 中。

例如在这里我想为变量 {{errorMessage}}

提供翻译
....
err => {
   this.errorMessage = 'Please check your credentials...!';
}
....

有没有办法在翻译文件中使用/添加此类内容的翻译:messages.es.xlfmessages.fr.xlf

我一直在寻找,在 i18n 开发的实际状态/阶段似乎不可用或至少不可能...i18n: Able to use translation strings outside a template

【问题讨论】:

  • 这就是第三方 i18n 扩展的用途。

标签: angular internationalization


【解决方案1】:

问题已解决。运行时直接将动态内容的翻译添加到message.*.xlf 文件中:ng xi18n。它为动态文本 interpolation 添加了以下内容,例如<source><x id="INTERPOLATION" equiv-text="{{ myDynamicText }}"/></source>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-20
    • 2014-12-03
    • 2019-03-12
    • 2021-12-16
    • 1970-01-01
    • 2021-07-19
    相关资源
    最近更新 更多