我已经用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>发布于 2016-09-20 11:11:11
您的资源是无效的XML:尝试删除id:="name"中的冒号,看看它是否有任何区别。
发布于 2018-08-21 02:11:36
几个小时以来,我一直在努力解决一个非常相似的问题。如果您已经使用Translations为另一种语言生成了strings.xml文件,则还需要将(xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2")放在新的xml文件上。否则,您将得到一个The prefix ”xliff“ for element ”xliff:g“ is not bound错误。我希望这能帮助那些可能还在谷歌上搜索这个的人。
发布于 2016-09-15 20:48:24
因此,strings.xml中的字符串与常规字符串的行为略有不同。您需要转义(分隔)某些字符。您可以保存下表。
替换< < for >的<>
将&替换为和"'"替换为‘替换"为\\’
因此,在您的例子中,它是">xliff:g“。
也跟着这个>。这应该能解决你的问题。如果没有的话请告诉我。
https://stackoverflow.com/questions/39519888
复制相似问题