美文网首页
Android 多语言部分不翻译

Android 多语言部分不翻译

作者: 念念不忘_2016 | 来源:发表于2021-08-31 19:19 被阅读0次

按钮文字的翻译不如文本框中文字的翻译灵活。标记消息中不应该翻译的部分
字符串中常常包含不应翻译成其他语言的文本。常见的示例包括一段代码、某个值的占位符、特殊符号或名称。准备字符串进行翻译时,请查找并标记应保持原样不进行翻译的文本,以避免翻译人员对其进行更改。

要标记不应翻译的文本,可以使用 <xliff:g> 占位符标记。以下标记示例可以确保文本“%1$s”在翻译过程中不会被更改(否则它会破坏消息):

<string name="countdown">
  <xliff:g id="time" example="5 days">%1$s</xliff:g> until holiday
</string>

在声明占位符标记时,请务必添加一个 ID 属性来说明此占位符的用途。如果您的应用稍后会替换占位符的值,请务必提供属性示例来说明预期的用途。

以下是一些其他占位符标记的示例:

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Example placeholder for a special unicode symbol -->
<string name="star_rating">Check out our 5
    <xliff:g id="star">\u2605</xliff:g>
</string>
<!-- Example placeholder for a for a URL -->
<string name="app_homeurl">
    Visit us at <xliff:g
    id="application_homepage">http://my/app/home.html</xliff:g>
</string>
<!-- Example placeholder for a name -->
<string name="prod_name">
    Learn more at <xliff:g id="prod_gamegroup">Game Group</xliff:g>
</string>
<!-- Example placeholder for a literal -->
<string name="promo_message">
    Please use the "<xliff:g id="promotion_code">ABCDEFG</xliff:g>" to get a discount.
</string>
...
</resources>

相关文章

网友评论

      本文标题:Android 多语言部分不翻译

      本文链接:https://www.haomeiwen.com/subject/gsaziltx.html