Android xliff和字符串资源

      XLIFF is an XML-based format that enables translators to concentrate on the text to be translated. Likewise, since it's a standard, manipulating XLIFF files makes localization engineering easier: once you have converters written for your source file formats, you can simply write new tools to deal with XLIFF and not worry about the original file format. It also supports a full localization process by providing tags and attributes for review comments, the translation status of individual strings, and metrics such as word counts of the source sentences

       很多Android开发者可能会发现部分资源字符串在/res/values/string.xml中包含有类似xliff的节点,Xliff是XML Localization Interchange File Format 的缩写,中文名为XML本地化数据交换格式,对于在Android的资源字符串中,可能会有类似下面的 <xliff:g id="FILE_NAME">%1$s</xliff:g> 这里,id我们可以随便定义,后面的%1$s有点像C#中的字符串格式化标志,这里1%表示这是第一个可替换量,如果一个String中有多个需要替换的变量,可以为 

   <string name="wangjieming">
    hello<xliff:g id="FILE_NAME">%1$s</xliff:g>aaaaaaaaaaaaa
        <xliff:g id="EXACT_REASON">%2$s</xliff:g>
    "</string>


TextView tv = (TextView) findViewById(R.id.textView1);

        String info = getResources().getString(R.string.wangjieming,"wangjieming","13312344321");

        tv.setText(info);

 

这句话很重要哦~

在String里增加XLIFF的 xmlns 就OK了

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">


你可能感兴趣的:(android,String,File,localization,attributes,translation)