简体   繁体   English

不要使用 i18n angular 翻译字符串中的单词

[英]Do not translate a word in the string using i18n angular

I use i18n angular for internationalization application.我使用 i18n angular 进行国际化应用。
I want to translate a string except the one word in the middle of the string.我想翻译一个字符串,除了字符串中间的一个单词。
In practice this word could be the abbreviation or the name of the company.在实践中,这个词可以是公司的缩写或名称。
(ex translate from English to Spanish) (例如从英语翻译成西班牙语)
English:英语:
'This is a test Message for translation.' '这是一个用于翻译的测试消息
Spanish (Actual result) :西班牙语(实际结果):
'Este es un mensaje de prueba para traducción.' 'Este es un mensaje de prueba para traducción。'
Spanish (expected result):西班牙语(预期结果):
'Este es un Message de prueba para traducción.' 'Este es un Message de prueba para traducción。

I have the only one solution - wrap string to the separated span:我只有一种解决方案 - 将字符串包装到分隔的跨度:

<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>

Do someone has a more convenient or common solution?有人有更方便或更通用的解决方案吗?
Thanks.谢谢。

I believe you can use interpolation inside of i18ed string我相信您可以在 i18ed 字符串中使用插值

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

and it would be transformed into a string with interpolation in the middle它会被转换成一个中间插值的字符串

<source> This is a test <x id="INTERPOLATION"...> for translation</source>

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

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