gpt4 book ai didi

带有 xliff :g inserts a blank space 的 Android 字符串格式

转载 作者:行者123 更新时间:2023-11-29 01:28:18 24 4
gpt4 key购买 nike

我想我发现了 Android 如何使用 <xliff:g> 解析字符串的错误。标签。

这里有两个示例字符串:

<string name="test">
blah blah %1$s %2$s blah blah ...
</string>

结果是“blah blah $argument1 $argument2 blah blah ...”。好!

<xliff:g>相同的字符串标签:

<string name="test">
blah blah
<xliff:g id="firstArgument" example="ha">%1$s</xliff:g>
<xliff:g id="secondArgument" example="haha">%2$s</xliff:g>
blah blah ...
</string>

结果是……“blah blah $argument1 $argument2 blah blah ...”。为什么字符串前面有一个空格?

除了显而易见的之外,任何人都知道任何解决方法

<string name="test">blah blah 
<xliff:g id="firstArgument" example="ha">%1$s</xliff:g>
<xliff:g id="secondArgument" example="haha">%2$s</xliff:g>
blah blah ...
</string>

因为那看起来很丑。

最佳答案

我遇到了完全相同的问题。如果您在开始/结束字符串标记之间有任何空格,它将包含在最终字符串中。在上面的示例中,字符串的末尾还将在“...”之后包含一个空格

如果你想避免额外的尾随空格:

<string name="test">blah blah 
<xliff:g id="firstArgument" example="ha">%1$s</xliff:g>
<xliff:g id="secondArgument" example="haha">%2$s</xliff:g>
blah blah ...</string>

令人惊讶的是文档没有提到这一点: https://developer.android.com/distribute/tools/localization-checklist.html

可能值得提交一个错误来报告这一点。

关于带有 xliff :g inserts a blank space 的 Android 字符串格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32637021/

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