angular-i18n select 属性中的语法
angular-i18n select syntax in attribute
我正在尝试使用 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>
这似乎是 Angular
的一个众所周知的问题
Allow ICU messages in attributes [blocked, requires an update of the pars
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" />
我正在尝试使用 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>
这似乎是 Angular
的一个众所周知的问题Allow ICU messages in attributes [blocked, requires an update of the pars
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" />