0

I'm learning about localization and displaying the text, depending on the default locale settings on the device.

one line of code is making problems and I can't really figure out why, because the example project has the exact same code just without any errors.

strings.xml

<!--
  Whipped cream topping for the order summary. It will be shown in the format of
  "Add whipped cream? true" or "Add whipped cream? false". [CHAR LIMIT=NONE]
-->
<string name="order_summary_whipped_cream">Add Whipped Cream? 
<xliff:g id="hasWhippedCream" example="true">%b</xliff:g></string>

<!--
  Chocolate topping for the order summary. It will be shown in the format of
  "Add chocolate? true" or "Add chocolate? false". [CHAR LIMIT=NONE]
-->
<string name="order_summary_chocolate">Add Chocolate? 
<xliff:g id="hasChocolate" example="true">%b</xliff:g></string>

MainActivity.js

/**
 * This method creates the string to display
 */
private String createOrderSummary
(String enteredName, int price, boolean hasWhippedCream, boolean hasChocolate)
{
    String orderSummary = getString(R.string.order_summary_name, enteredName)
                 + "\n" + getString(R.string.order_summary_whipped_cream, hasWhippedCream)
                 + "\n" + getString(R.string.order_summary_chocolate, hasChocolate)
                 + "\n" + getString(R.string.order_summary_quantity, quantity)
                 + "\n" + getString(R.string.order_summary_price, price)
                 + "\n" + getString(R.string.thank_you);

    return orderSummary;
}

getString(R.string.order_summary_chocolate, hasChocolate) is underlined red and shows this

I don't really understand, why the first string order_summary_whipped_cream works perfectly fine and order_summary_chocolate gives me those errors - they're the same, only the name differs

hope I'm not overseeing anything obvious :/

0 Answers0