gpt4 book ai didi

android - 使用 XLIFF 改进 Android 字符串资源

转载 作者:可可西里 更新时间:2023-11-01 18:45:38 27 4
gpt4 key购买 nike

我见过一些使用 XLIFF 标签来包装变量的 Google 应用程序和代码示例。我看到这样做有一些很大的优势,特别是对于替换非描述性格式参数,例如 %1$s .

不幸的是,XLIFF 似乎没有很好地集成到 ADT 中。以下面的字符串资源为例:

<resources 
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"
xmlns:tools="http://schemas.android.com/tools">

<string name="share_with_application">
Share your score of <xliff:g id="score" example="1337">%1$s</xliff:g>
with <xliff:g id="application_name" example="Bluetooth">%2$s</xliff:g>!
</string>

</resources>

Graphical Layout preview

在上面的例子中,字符串在第一个 <xliff> 之后被截断了标签。人们还会期待 example要使用的属性,导致图形预览显示:

Share your score of 1337 with Bluetooth!

目前在我的字符串资源中使用 XLIFF 标签有什么好处吗?

最佳答案

我们刚刚在 Android Studio 0.3 版本中添加了对此的支持: https://android-review.googlesource.com/#/c/67724/

关于android - 使用 XLIFF 改进 Android 字符串资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11331809/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com