【问题标题】:Do not translate a word in the string using i18n angular不要使用 i18n angular 翻译字符串中的单词
【发布时间】:2021-06-30 14:08:15
【问题描述】:

我使用 i18n angular 进行国际化应用。
我想翻译一个字符串,除了字符串中间的一个单词。
在实践中,这个词可以是公司的缩写或名称。
(例如从英语翻译成西班牙语)
英语:
'这是一个翻译测试消息。'
西班牙语(实际结果):
'Este es un mensaje de prueba para traducción.'
西班牙语(预期结果):
'Este es un Message de prueba para traducción。'

我只有一个解决方案 - 将字符串包装到分隔跨度:

<span i18n="Test part1: This is a test@@TestPart1"> This is a test </span>
<span>Message</span>
<span i18n="Test part2: for translation@@TestPart2">for translation</span>

有人有更方便或更通用的解决方案吗?
谢谢。

【问题讨论】:

  • 好吧,据我所知,您应该配置了两个字符串,因此,您将在每个文件中包含两个短语或您用来翻译的任何内容,例如,使用 angular i18n 默认值,您将拥有 2 个带有短语的 xml 文件。

标签: angular string localization internationalization


【解决方案1】:

我相信你可以在 i18n 字符串中使用插值

<span i18n="@@Test"> This is a test {{msgStr}} for translation</span>

它会被转换成一个中间插值的字符串

<source> This is a test <x id="INTERPOLATION" equiv-text="{{msgStr}}" /> for translation</source>

<target state="final"> Este es un <x id="INTERPOLATION" equiv-text="{{msgStr}}" /> de prueba para traducción. </target>

【讨论】:

    猜你喜欢
    • 2015-06-07
    • 1970-01-01
    • 2019-01-05
    • 1970-01-01
    • 2014-03-27
    • 1970-01-01
    • 1970-01-01
    • 2011-08-31
    相关资源
    最近更新 更多