在我的strings.xml中使用xliff标签时遇到问题

时间:2015-10-23 15:51:54

标签: android internationalization

我已经阅读了官方文档并了解了其他人在SO上做了什么,但是在添加xliff标签后我无法使用我的字符串。我导入了xliff名称空间

的strings.xml

String raw = getString(R.string.string_name);
return String.format(raw, customGoal.getGoalValueLow(), units, customGoal.getGoalValueHigh(), units);

ShapeContainer

1 个答案:

答案 0 :(得分:1)

我手边没有Android Studio来重现你的问题,但是这里有一个疯狂的猜测可能是错的:

XLIFF标准未列出example元素的属性<g>(请参阅here)。尝试删除它们会产生影响。 XLIFF允许您添加自己的属性,但如果您这样做,属性值应以&#39; x - &#39;开头。 (见here)。

如果您想通知翻译者占位符代表什么,您还可以使用ctype属性,或选择更具描述性的ID:

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="string_name">
        Your goal is maintaining your levels between 
        <xliff:g id="maxValue" ctype="x-number">%1$d</xliff:g>
        <xliff:g id="measurementUnit" ctype="x-unit">%2$s</xliff:g>and 
        <xliff:g id="minValue" ctype="x-number">%3$d</xliff:g>
        <xliff:g id="measurementUnit" ctype="x-unit">%2$s</xliff:g>
</string>