什么是"msgid"?和"xliff"在strings.xml文件中? [英] What's "msgid" and "xliff" in strings.xml file?

查看:828
本文介绍了什么是"msgid"?和"xliff"在strings.xml文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候,我会在Google的示例生成的"strings.xml"文件上看到一些奇怪的属性,例如,在 芯片示例 (可用代码 此处 ),我可以找到"res/values-en-rGB"(适用于英语-英国)的字符串文件:

Sometimes I see some weird attributes on the "strings.xml" file made by Google's samples, for example, on the chips example (code available here), I can find this strings file of "res/values-en-rGB" (for English-Britain) :

<resources xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="more_string" msgid="8495478259330621990">"+<xliff:g id="COUNT">%1$s</xliff:g>"</string>
    <string name="copy_email" msgid="7869435992461603532">"Copy email address"</string>
    <string name="copy_number" msgid="530057841276106843">"Copy phone number"</string>
    <string name="done" msgid="2356320650733788862">"Return"</string>
</resources>

我认为两者都只用于本地化字符串,因为我从未在"res/values"文件夹中看到它们.

I think both are used only for localized strings, as I never saw them inside "res/values" folder.

这些属性是什么意思?

What do those attributes mean?

"xliff"的值是什么意思?

What does the value of "xliff" mean?

什么时候应该使用它们以及应该放在哪里?

When should you use them and what should you put there?

他们甚至需要吗?

是否有关于这些东西的文档?

Is there any documentation about those things?

推荐答案

在Android开发人员上xliff.

On Android Developers Localise your app page, search for xliff in the section named "Mark message parts that should not be translated".

说明如下:

通常字符串中包含不应翻译为的文本 其他语言.常见的示例可能是一段代码, 值,特殊符号或名称的占位符.当你准备 您的翻译字符串,查找并标记应 保持原样,无需翻译,因此翻译人员不会 更改它.

Often strings contain contain text that should not be translated into other languages. Common examples might be a piece of code, a placeholder for a value, a special symbol, or a name. As you prepare your strings for translation, look for and mark text that should remain as-is, without translation, so that the translator doesn't change it.

要标记不应翻译的文本,请使用 占位符标记.

To mark text that should not be translated, use an placeholder tag.

建议不要翻译<xliff:g></xliff:g>标记内的文本.这些标签还可以提供有关非翻译文本的元数据.

The suggestion is that text within the <xliff:g></xliff:g> tags should not be translated. These tags can also provide metadata about the non-translated text.

声明占位符标记时,请始终添加一个id属性,该属性应 解释占位符的用途.如果您的应用程序稍后更换 占位符值,请务必提供示例属性来阐明 预期的用途.

When you declare a placeholder tag, always add an id attribute that explains what the placeholder is for. If your apps later replace the placeholder value, be sure to provide an example attribute to clarify the expected use.


有关实际xliff工具的更多信息,而不是其与Android字符串的关系,请查看相关问题:


For more information on the actual xliff tool, rather than how it relates to Android strings, check out the related question:

这篇关于什么是"msgid"?和"xliff"在strings.xml文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆