【问题标题】:Localization xliff error message本地化 xliff 错误消息
【发布时间】:2016-09-15 20:32:44
【问题描述】:

我使用 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>

【问题讨论】:

    标签: java android xml string xliff


    【解决方案1】:

    您的资源不是有效的 XML:尝试删除 id:="name" 中的冒号,看看是否有任何不同。

    【讨论】:

      【解决方案2】:

      我为一个非常相似的问题苦苦挣扎了好几个小时。 如果您使用翻译编辑器为另一种语言生成了 strings.xml 文件,您还需要将 (xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2") 放在新的 xml 文件中。否则你会得到一个The prefix ”xliff“ for element ”xliff:g“ is not bound 错误。我希望这对可能仍在谷歌搜索的其他人有所帮助。

      【讨论】:

        【解决方案3】:

        因此 strings.xml 中的字符串的行为与常规字符串略有不同。 您需要转义(分隔)某些字符。您可以保存下表。

        将&amp;gt; 替换为&lt; 替换为 >
        替换 &amp;amp; 为 & 将 "'" 替换为 ' 将 &amp;quot 替换为 \"\"

        所以在你的情况下,它正在查看 ">xliff:g" 。

        也按照此操作 >。这应该可以解决您的问题。如果没有,请告诉我。

        【讨论】:

        • 抱歉,我无法理解您建议的表格...我的 strings.xml 文件中的哪些字符需要转义?
        • 进行了更改。这应该更有意义。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-30
        • 2021-07-06
        • 2011-06-07
        • 1970-01-01
        相关资源
        最近更新 更多