Improving Android string resources with XLIFF

荒凉一梦 提交于 2019-12-04 23:12:54

We've just added support for this in Android Studio, for version 0.3: https://android-review.googlesource.com/#/c/67724/

Just to be clear, the use of XLIFF tags in Android string resources is fully documented at

https://developer.android.com/distribute/tools/localization-checklist.html#manage-strings

Such strings work fine even in Eclipse builds (the support is in the aapt tool that builds the apps).

However, as illustrated in the question, the graphical layout tools contained in the ADT don't make any allowance for the xliff tag, merely truncating the string after the first such marked up sub-string.

The graphical tools in Android Studio do cope well with such strings, knowing about, and making use of the xliff markup.

I actually find that the full <xliff:g> is rather verbose in my source code, so I adjust the namepsace declaration to allow me to use just <x:g> thus:

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

   <string name="greeting">Hello <x:g id="name">%1$s</x:g>!</string>

</resources>

Having now gotten my hands dirty with building AOSP from source, CommonsWare is correct: that build process is entirely different and indeed many AOSP apps contain XLIFF tags. It's too bad this doesn't integrate with ADT, but it is as it is.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!