我创建了一个带有 xliff 的资源字符串,但是在运行应用程序时遇到错误:
Error:(17, 52) Error: The prefix "id" for attribute "id:" associated with an element type "xliff:g" is not bound.
Error:Execution failed for task ':app:mergeDebugResources'.
> C:\Users\msanli\AndroidStudioProjects\JustJava\app\src\main\res\values\strings.xml:17:52: Error: The prefix "id" for attribute "id:" associated with an element type "xliff:g" is not bound.
我已经在我的资源附近添加了这个,所以我不确定发生了什么
(xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2").
感谢任何帮助!
资源:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">Just Java</string>
<string name="hint_name">Name</string>
<string name="toppings_header">Toppings</string>
<string name="whipped_cream">Whipped Cream</string>
<string name="chocolate">Chocolate</string>
<string name="quantity_header">Quantity</string>
<string name="decrement_minus">-</string>
<string name="quantity_text">1</string>
<string name="increment_plus">+</string>
<string name="order_text">Order</string>
<string name="max_coffee_toast">You cannot have more than 100 cups of coffee</string>
<string name="min_coffee_toast">You cannot have less than 1 cup of coffee</string>
<string name="admin_email"></string>
<string name="email_order_subject">Just Java Order Summary For </string>
<string name="name_order_summary">
Name: <xliff:g id:="name" example="Samuel">%s</xliff:g>
</string>
<string name="whipped_cream_ordered">Add Whipped Cream? </string>
<string name="chocolate_ordered">Add Chocolate? </string>
<string name="quantity">Quantity: </string>
<string name="total_price">Total Price: $</string>
<string name="thank_you">Thank You!</string>
</resources>
答案 0 :(得分:1)
您的资源无效XML:尝试删除id:="name"
中的冒号,看看它是否有所不同。
答案 1 :(得分:1)
我在一个非常类似的问题上挣扎了好几个小时。
如果您已经使用“翻译编辑器”为另一种语言生成了一个strings.xml文件,则还需要将from itertools import combinations
teams = "abcdefgh"
possible_games = combinations(teams, 2)
doubles = {"a":("b", "c", "d"), "b":("c", "d"), "c":("d",), "e":("f", "g", "h"), "f":("g", "h"), "g":("h",)}
all_doubles = {(k, v) for k, values in doubles.iteritems() for v in values}
print all_doubles
games = list(possible_games)
games += [g for g in games if g in all_doubles]
print games, len(games)
放在新的xml文件中。否则,您将收到(xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2")
错误。我希望这对仍在使用此功能的其他人有所帮助。
答案 2 :(得分:0)
因此,strings.xml中的字符串与常规字符串的行为略有不同。 您需要转义(分隔)某些字符。您可以保存下表。
将>
替换为&lt;
将<
替换为&gt;
将&
替换为&amp;
将"'"
替换为&#39;
替换{&#34; \&#34;
"
所以在你的情况下,它正在看&#34;&amp; gt; xliff:g&#34;
关注此&gt;同样。这应该可以解决您的问题。如果不是,请告诉我。