0

我正在使用根据 google 的翻译服务准备的 strings.xml 文件,该文件指定您不想翻译的字符串部分应包含在 xliff:g 标记中,如下所示:<xliff:g>some text</xliff:g>

例如,我的 strings.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:xliff="rn:oasis:names:tc:xliff:document:1.2">
    <string name="game_starts_now">Game Starts Now</string>
    <string name="game_starts_in">Game Starts In <xliff:g id="seconds" example="20">{0}</xliff:g> seconds</string>
</resources>

如果我通过搜索名称“game_starts_now”来追踪第一个值,它会按预期追踪,但如果我追踪“game_starts_in”,它会给出它存在的完整 xml 节点。

例子:

trace((xml.string.(@name == "game_starts_now"))); // Game Starts Now
trace((xml.string.(@name == "game_starts_in"))); // [output is next 4 lines]
// <string name="game_starts_in" xmlns:xliff="rn:oasis:names:tc:xliff:document:1.2">
//  Game Starts In
//  <xliff:g id="seconds" example="20">{0}</xliff:g>
// </string>

有没有办法获得<string>没有子节点的完整内部文本?我想让第二个跟踪输出以下文本:

Game Starts In {0} seconds

4

1 回答 1

0

访问 XML 的子节点的方法是使用点符号,就像使用任何普通对象一样。我会尝试使用 trace((xml.string.(@ == "game_starts_in").(@id =="seconds")));

让我知道这是否适合您。

于 2014-12-08T17:59:57.947 回答