我试图使用i18n SELECT语法翻译输入字段的占位符:
<input placeholder="{userRole, admin{you are an admin} other {you are a user}}" i18n-placeholder="MYAPP.PLACEHOLDER|my placeholder">
这导致以下xlf文件条目:
<trans-unit id="85f60a0a03b3b4e189252fc0157dd403e806bbcc" datatype="html">
<source>{userRole, admin{you are an admin} other {you are a user}}</source>
<context-group purpose="location">
<context context-type="sourcefile">path/to/my/file.component.ts</context>
<context context-type="linenumber">4</context>
</context-group>
<note priority="1" from="description">my placeholder</note>
<note priority="1" from="meaning">MYAPP.PLACEHOLDER</note>
</trans-unit>
因此似乎无法识别SELECT语法。当我使用语法不翻译属性但是元素的内容时,.xlf标记看起来像这样:
<source>{VAR_SELECT, admin{you are an admin} other {you are a user}}</source>
答案 0 :(得分:6)
这似乎是Angular
的一个众所周知的问题允许属性中的ICU消息[被阻止,需要更新文档
https://github.com/angular/angular/issues/16477
解决方法是使用其他标记来实现翻译:
<span i18n='SOME_TITLE|Description Text' #translatedPlaceholder>{VAR_SELECT, admin{you are an admin} other {you are a user}}</span>
<input [placeholder]="translatedPlaceholder.textContent" />