XLIFF (XML Localisation Interchange File Format) is an XML-based format created to standardizelocalization.
XLIFF(xml 本地化交换文件格式)是基于XML用于本地语音标准化。
http://en.wikipedia.org/wiki/XLIFF 写道
Description
An XLIFF document is composed of one or more <file> elements. Each <file> element corresponds to an original file or source (i.e. database table). A <file> contains the source of the localizable data and, once translated, the corresponding localized data for one, and only one, locale.
Localizable data are stored in <trans-unit> elements. The <trans-unit> element holds a <source> element to store the source text, and a <target> element to store the latest translated text. The <target> elements are not mandatory.
<trans-unit id="1">
<source xml:lang="en">Cannot find the file.</source>
<target xml:lang="fr">Fichier non trouvé.</target>
</trans-unit>
android中的strings.xml,需要resources中加入命名空间
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="string_search">character \'<xliff:g id="string">%s</xliff:g>\': </string>
</resources>
注意到绿色,是xliff标签
在android程序中就可以如下使用
getString(R.string.string_search, "参数")
具体getString用法参见如下android文档
public final String getString (int resId, Object... formatArgs)
Return a localized formatted string from the application's package's default string table, substituting the format arguments as defined in Formatter
and format(String, Object...)
.
Parameters
resId
formatArgs
Resource id for the format string |
The format arguments that will be used for substitution. |