Android xliff和字符串资源(Error parsing XML: unbound prefix)

50 篇文章 2 订阅
29 篇文章 2 订阅

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">


我在没有添加这句话的情况下出现了Error parsing XML: unbound prefix错误,花了很长时间没有发现,最后才发现原来是没有添加上面这句话啊,望大家切记~


xliff参考链接:http://blog.csdn.net/hustpzb/article/details/6870817

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值