Skip to content

Instantly share code, notes, and snippets.

@udacityandroid
Last active February 6, 2023 17:58
  • Star 60 You must be signed in to star a gist
  • Fork 46 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save udacityandroid/759b8b4c9ed9e6806e90 to your computer and use it in GitHub Desktop.
Android for Beginners : Spanish Localization Solution. This would be saved in the res/values-es/strings.xml file.
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Title for the application. [CHAR LIMIT=12] -->
<string name="app_name">Sólo Java</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="name">Nombre</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">Ingredientes</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="whipped_cream">Crema batida</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="chocolate">Chocolate</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="quantity">Cantidad</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=5] -->
<string name="initial_quantity_value">2</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="order">Ordenar</string>
<!--
Name for the order summary. It will be shown in the format of "Name: Amy" where Amy is the
user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_name">Nombre: <xliff:g id="name" example="Amy">%s</xliff:g></string>
<!--
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">Agregue la crema batida? <xliff:g id="addWhippedCream" 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">Agregue el chocolate? <xliff:g id="addChocolate" example="true">%b</xliff:g></string>
<!--
Quantity of coffee cups for the order summary. It will be shown in the format of
"Quantity: 2", where 2 is the number of cups ordered. [CHAR LIMIT=NONE]
-->
<string name="order_summary_quantity">Cantidad: <xliff:g id="quantity" example="2">%d</xliff:g></string>
<!--
Total price for the order summary. It will be shown in the format of
"Total: $10" where $10 is the price. [CHAR LIMIT=NONE]
-->
<string name="order_summary_price">Total: <xliff:g id="price" example="$10">%s</xliff:g></string>
<!-- Thank you message for the order summary. [CHAR LIMIT=NONE] -->
<string name="thank_you">¡Gracias!</string>
<!--
Subject line for the order summary email. It will be in the format of
"Just Java order for Amy" where Amy is the user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_email_subject">Sólo java para <xliff:g id="name" example="Amy">%s</xliff:g></string>
</resources>
@Hoab
Copy link

Hoab commented Apr 18, 2018

In case anyone have the error "Format string "XXXXX" is not valid format string so it should not be passed to String.format"

You need to check the string.xml file of the second languaje. You must add the same line than the one in English
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"

and, the string in the second languaje also need to have the whole line
"whatever_you_are_translating " <xliff:g id="xxx" example="xxxxxx">%s</xliff:g>

You may need to Rebuild the project after

@pokumars
Copy link

Finnish

<string name="app_name">Just Java</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">Täytteet</string>

<!--
 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]

-->
Kermavaahto

<!--
 Chocolate topping for the order summary. It will be shown in the format of
 "Add chocolate? true" or "Add chocolate? false". [CHAR LIMIT=NONE]

-->
Suklaa

<!--
      Quantity of coffee cups for the order summary. It will be shown in the format of
      "Quantity: 2", where 2 is the number of cups ordered. [CHAR LIMIT=NONE]
    -->
<string name="quantity">määrä</string>


<string name="order">Tilaa</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
   <string name="type_name_here">kirjoita nimi tähän</string>

<!-- Thank you message for the order summary. [CHAR LIMIT=NONE] -->
   <string name="thank_you">Kiitos</string>

<!--
  Name for the order summary. It will be shown in the format of "Name: Amy" where Amy is the
  user's name. [CHAR LIMIT=NONE]
-->
   <string name="name">
       Nimi :<xliff:g id= "name of customer" example = "John"> %S</xliff:g>
<!--
  Total price for the order summary. It will be shown in the format of
  "Total: $10" where $10 is the price. [CHAR LIMIT=NONE]
-->
   <string name="Total">Yhteensä</string>

<!--Toast message when the order is less than 1. It will be shown in the format of
"You cannot have less than 1 coffee" . [CHAR LIMIT=NONE]
-->
<string name="less_than_1">Ei pysyty tilaaman alle 1 kahvia</string>

<!--Toast message when the order is more than 100. It will be shown in the format of
    "You cannot have more than 100 coffees" . [CHAR LIMIT=NONE]
    -->
<string name="more_than_100">Et saa yli 100 kahvia</string>

<!--

Email subject text for order summary.
It will be shown in the format Just Java order for John
-->

Just Java Order tilaus asiakkaalle :<xliff:g id= "name of customer" example = "John"> </xliff:g>

@Eduese
Copy link

Eduese commented May 31, 2018

Things became easier when I found this code for the Spanish language. I want to commend others who's helped in other languages.

@sahillearner
Copy link

sserror
hi guys , if anyone can help with this error please.

@ierosvin
Copy link

ierosvin commented Jun 20, 2018

Bicol Region, Philippines

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">Ining Java</string>
    <string name="name">Ngaran</string>
    <string name="toppings">Pampasiram</string>
    <string name="whipped_cream">Pampadakula</string>
    <string name="chocolate">Tsokolate</string>
    <string name="quantity">Pira</string>
    <string name="initial_quantity_value">2</string>
    <string name="order">Pagibo</string>
    <string name="order_summary_name">Ngaran: <xliff:g id="name" example="Amy">%s</xliff:g></string>
    <string name="order_summary_whipped_cream">Gusto mo magdakula? <xliff:g example="true" id="addWhippedCream">%b</xliff:g></string>
    <string name="order_summary_chocolate">Gusto mo tsokolate? <xliff:g example="true" id="addChocolate">%b</xliff:g></string>
    <string name="order_summary_quantity">Kantidad: <xliff:g example="2" id="quantity">%d</xliff:g></string>
    <string name="order_summary_price">Sumatotal: <xliff:g id="price" example="$10">%s</xliff:g></string>
    <string name="thank_you">Mabalos!</string>
    <string name="order_summary_email_subject">Ining Java para kan <xliff:g example="Amy" id="name">%s</xliff:g></string>
</resources>

@Fury4hwxc
Copy link

thanks 👍

@lycansre
Copy link

lycansre commented Jul 4, 2018

Translation in arabic
الترجمة للعربية

فقط Java
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="name">الاسم</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">الاضافات</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="whipped_cream">كريمة</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="chocolate">الشوكولاتا</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="quantity">الكمية</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=5] -->
<string name="initial_quantity_value">2</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="order">اطلب</string>

<!--
  Name for the order summary. It will be shown in the format of "Name: Amy" where Amy is the
  user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_name">الاسم: <xliff:g id="name" example="Amy">%s</xliff:g></string>

<!--
  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">اضف الكريمة? <xliff:g id="addWhippedCream" 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">اضف الشوكولاتا? <xliff:g id="addChocolate" example="true">%b</xliff:g></string>

<!--
  Quantity of coffee cups for the order summary. It will be shown in the format of
  "Quantity: 2", where 2 is the number of cups ordered. [CHAR LIMIT=NONE]
-->
<string name="order_summary_quantity">الكمية: <xliff:g id="quantity" example="2">%d</xliff:g></string>

<!--
  Total price for the order summary. It will be shown in the format of
  "Total: $10" where $10 is the price. [CHAR LIMIT=NONE]
-->
<string name="order_summary_price">الحساب: <xliff:g id="price" example="$10">%s</xliff:g></string>

<!-- Thank you message for the order summary. [CHAR LIMIT=NONE] -->
<string name="thank_you">شكراً!</string>

<!--
  Subject line for the order summary email. It will be in the format of
  "Just Java order for Amy" where Amy is the user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_email_subject">فقط java <xliff:g id="name" example="Amy">%s</xliff:g></string>

@Alizoo
Copy link

Alizoo commented Jul 17, 2018

Having initial_quantity_value in every translation of the strings.xml file would cause a massive headache if the developer ever needed to change that value. I would suggest having the initial_quantity_value in the original strings.xml file with 'translatable = "false"' in the string tag. Then omit it from all other translations of the strings.xml file.

@teonkajkafon
Copy link

teonkajkafon commented Jul 20, 2018

Right to left languages: This is Arabic mostly from google translate, but I was trying to format it correctly rather than get a correct translation. I don't actually understand why this would work correctly on my phone (after setting phone to Arabic language) since I would have expect the tags to be set before the colons in order for it to display correctly. Maybe it's because I didn't type in the Arabic directly, but copied and pasted it (so I had to copy the right to left colon etc)?

image

Copy link

ghost commented Aug 10, 2018

~ KOREAN~

대한민국
한국어가 제일 느낌있네

저스트 자바
<!--Header text for the list of toppings [CHAR LIMIT=20]-->
<string name="toppings">토핑</string>

<!-- HINT text display in the empty field for the user's name [CHAR LIMIT=NONE]-->
<string name="enter_name">이름</string>

<!-- HINT Whipped Cream check box [CHAR LIMIT=20]-->
<string name="whipped_cream">휘핑크림</string>

<!-- HINT chocolate check box [CHAR LIMIT=NONE]-->
<string name="chocolate">초콜릿</string>

<!-- HINT Text showing QUANTITY [CHAR LIMIT=20]-->
<string name="quantity">갯수</string>

<!-- HINT Text showing ORDER SUMMARY [CHAR LIMIT=20]-->
<string name="order_summary">주문내역</string>

<!-- HINT ORDER button [CHAR LIMIT=20]-->
<string name="order">주문</string>

<!--Name of the order summary. It will be shown in the format of "Name: David"
where David is the user's name. [CHAR LIMIT=NONE]-->
<string name="order_summary_name">이름 <xliff:g id="이름 " example="David">%s</xliff:g></string>

<!--In the order summary, will be shown in the format of
"Add Whipped Cream? true" or "Add Whipped Cream? false" [CHAR LIMIT=NONE]-->
<string name="add_whipped_cream">휘핑크림 추가? <xliff:g id="휘핑크림 추가? " example="true">%b</xliff:g></string>

<!--In the order summary, will be shown in the format of
"Add Chocolate? true" or "Add Chocolate false" [CHAR LIMIT=NONE]-->
<string name="add_chocolate">초콜릿 추가? <xliff:g id="초콜릿 추가? " example="true">%b</xliff:g></string>

<!--In the order summary, will be shown in the format of
"Quantity: 2" where 2 is the number of coffees ordered [CHAR LIMIT=NONE]-->
<string name="order_summary_quantity">갯수 <xliff:g id="갯수 " example="2">%d</xliff:g></string>

<!--In the order summary, will be shown in the format of
"Total: $12" where 12 is the total price of the coffees order [CHAR LIMIT=NONE]-->
<string name="order_summary_price">가격 <xliff:g id="가격 " example="12">%d</xliff:g></string>

<!--In the order summary, will be shown in the format of "Thank you!" [CHAR LIMIT=NONE]-->
<string name="thank_you">감사합니당!</string>

<!--When the user decrements order below 0, toasts a message saying
"Cannot order below 0" [CHAR LIMIT=NONE]-->
<string name="decrement_order">0개 미만 주문하실 수 없어용</string>

<!--When the user increments order above 100, toasts a message saying
"Cannot order above 100" [CHAR LIMIT=NONE]-->
<string name="increment_order">100개 이상 주문하실 수 없어용</string>

@Abdallah-alnajjar
Copy link

strings.xml

Just Java Hello world! Settings
<!--Header text for the list of toppings [CHAR LIMIT=20] -->
<string name="toppings">Toppings</string>

<!-- Thank you message for the order summary .[CHAR LIMIT=NONE] -->
<string name="thank_you">Thank you!</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="whipped_cream">Whipped cream</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="chocolate">Chocolate</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="quantity">Quantity</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="order">Order</string>

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="addWhippedCream">Add Whipped Cream?  <xliff:g id="addWhippedCream" example="true"></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]
-->
Add Chocolate? <xliff:g id="addChocolate" example="true"></xliff:g>

<!--
 Total price for the order summary. It will be shown in the format of
 "Total: $10" where $10 is the price. [CHAR LIMIT=NONE]

-->
Total:

<!--
 Subject line for the order summary email. It will be in the format of
 "Just Java order for Amy" where Amy is the user's name. [CHAR LIMIT=NONE]

-->
just java order for

<!-- Name for the order summary . It will be shown in the format
of "Name: Amy" where Amy is the user's name [CHAR LIMIT=NONE] -->
<string name="order_summary_name" translatable="false">Name: <xliff:g id="name" example="Amy"></xliff:g></string>
</resources>

(arabic)

الأسم

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->

إضافات

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->

كريمه

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->

شوكولاتة

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->

الكميه

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->

أطلب

<!--
  Name for the order summary. It will be shown in the format of "Name: Amy" where Amy is the
  user's name. [CHAR LIMIT=NONE]  -->

الأسم: <xliff:g id="name" example="Amy"></xliff:g>

<!--
  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]
-->

إضافة كريمه? <xliff:g id="addWhippedCream" example="true"></xliff:g>

<!--
  Chocolate topping for the order summary. It will be shown in the format of
  "Add chocolate? true" or "Add chocolate? false". [CHAR LIMIT=NONE]
-->

إضافة شوكولاتة؟ <xliff:g id="addChocolate" example="true"></xliff:g>

الأجمالى:

<!-- Thank you message for the order summary. [CHAR LIMIT=NONE] -->

شكراَ

<!--
  Subject line for the order summary email. It will be in the format of
  "Just Java order for Amy" where Amy is the user's name. [CHAR LIMIT=NONE]
-->

طلب جافا فقط الى

_____________________________________________________________________________________________________________________________________________-

(spain)

Sólo Java
    <!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
    <string name="name">Nombre: </string>

    <!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
    <string name="toppings">Ingredientes</string>

    <!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
    <string name="whipped_cream">Crema batida</string>

    <!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
    <string name="chocolate">Chocolate</string>

    <!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
    <string name="quantity">Cantidad</string>

    <!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
    <string name="order">Ordenar</string>

    <!--
      Name for the order summary. It will be shown in the format of "Name: Amy" where Amy is the
      user's name. [CHAR LIMIT=NONE]
    -->
    <string name="order_summary_name">Nombre: <xliff:g id="name" example="Amy"></xliff:g></string>

    <!--
      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="addWhippedCream">Agregue la crema batida? <xliff:g id="addWhippedCream" example="true"></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="addChocolate">Agregue el chocolate? <xliff:g id="addChocolate" example="true">%b</xliff:g></string>

    <!--
      Total price for the order summary. It will be shown in the format of
      "Total: $10" where $10 is the price. [CHAR LIMIT=NONE]
    -->
    <string name="Total">Total: </string>

    <!-- Thank you message for the order summary. [CHAR LIMIT=NONE] -->
    <string name="thank_you">Gracias!</string>

    <!--
      Subject line for the order summary email. It will be in the format of
      "Just Java order for Amy" where Amy is the user's name. [CHAR LIMIT=NONE]
    -->
    <string name="just_java_order_for">Sólo java para </string>
</resources>

@Venky-8
Copy link

Venky-8 commented Nov 26, 2018

Marathi Translations:
path: res/values-mr-rIN/strings.xml
screenshot 18

@Dharmesh40
Copy link

Gujarati Translations

Gujarati strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="app_name">માત્ર જાવા</string>
    <string name="name">નામ</string>
    <string name="toppings">ટોપિંગ્સ</string>
    <string name="whipped_cream">ફીણેલી મલાઈ</string>
    <string name="chocolate">ચોકલેટ</string>
    <string name="quantity">જથ્થો</string>
    <string name="initial_quantity_value">2</string>
    <string name="order">ઓર્ડર</string>
    <string name="order_summary_whipped_cream">ફીણેલી મલાઈ ઉમેરો છો? <xliff:g id="addWhippedCream" example="yes"> </xliff:g></string>
    <string name="order_summary_chocolate">ચોકલેટ ઉમેરો છો? <xliff:g id="addChocolate" example="yes"> </xliff:g></string>
    <string name="order_summary_quantity">જથ્થો: <xliff:g id="quantity" example="2">%d</xliff:g></string>
    <string name="order_summary_price">કુલ: <xliff:g id="price" example="$10">%s</xliff:g></string>
    <string name="thank_you">આભાર!</string>
    <string name="order_summary_email_subject">માત્ર જાવા ઓર્ડર <xliff:g id="name" example="Amy">%s</xliff:g></string>
    <string name="order_summary_name">નામ <xliff:g id="name" example="Amy">%s</xliff:g></string>
    <string name="less_then_1_coffee">તમને 1 થી ઓછી કૉફી ન મળી શકે</string>
    <string name="more_then_100_coffee">તમને 100 થી વધુ કૉફી ન મળી શકે</string>
    <string name="toppings_yes">હા</string>
    <string name="toppings_no">ના</string>
</resources>

Screenshot
gu strings xml

MainActivity.java to get yes/no instead of true/false

    private String createOrderSummary(String name, int price, boolean addWhippedCream, boolean addChocolate) {
        String priceMessage = getString(R.string.order_summary_name, name);
        priceMessage += "\n" + getString(R.string.order_summary_whipped_cream);
        if (addWhippedCream) {
            priceMessage += getString(R.string.toppings_yes);
        } else priceMessage += getString(R.string.toppings_no);
        priceMessage += "\n" + getString(R.string.order_summary_chocolate);
        if (addChocolate) {
            priceMessage += getString(R.string.toppings_yes);
        } else priceMessage += getString(R.string.toppings_no);
        priceMessage += "\n" + getString(R.string.order_summary_quantity, quantity);
        priceMessage += "\n" + getString(R.string.order_summary_price, NumberFormat.getCurrencyInstance().format(price));
        priceMessage += "\n" + getString(R.string.thank_you);
        return priceMessage;
    }

Screenshot
mod in main activity java

if you are getting %b before yes or no like %bYes or %b remove that %b from (look at the arrows in screenshot)
solution

just java app screenshot gujarati
just java gujarati

just java app screenshot english
just java english

Best of Luck Everybody!

@jhmluna
Copy link

jhmluna commented May 5, 2019

@Hoab

Thanks for your message.
Solved my problem.

@NarFooZ
Copy link

NarFooZ commented Jun 5, 2019

العربية Arabic

جافا فقط
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="name">اسم</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">اضافات</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="whipped_cream">كريمة مخفوقة</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="chocolate">شوكولاتة</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="quantity">الكمية</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=5] -->
<string name="initial_quantity_value">۲</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="order">اطلب</string>

<!--
  Name for the order summary. It will be shown in the format of "Name: Amy" where Amy is the
  user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_name">اسم: <xliff:g id="name" example="Amy">%s</xliff:g></string>

<!--
  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"> اضافة كريمة مخفوقة ؟ <xliff:g id="addWhippedCream" 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">اضافة شوكولاتة ؟ <xliff:g id="addChocolate" example="true">%b</xliff:g></string>

<!--
  Quantity of coffee cups for the order summary. It will be shown in the format of
  "Quantity: 2", where 2 is the number of cups ordered. [CHAR LIMIT=NONE]
-->
<string name="order_summary_quantity">الكمية: <xliff:g id="quantity" example="2">%d</xliff:g></string>

<!--
  Total price for the order summary. It will be shown in the format of
  "Total: $10" where $10 is the price. [CHAR LIMIT=NONE]
-->
<string name="order_summary_price">المجموع: <xliff:g id="price" example="$10">%s</xliff:g></string>

<!-- Thank you message for the order summary. [CHAR LIMIT=NONE] -->
<string name="thank_you">شكرا لك</string>

<!--
  Subject line for the order summary email. It will be in the format of
  "Just Java order for Amy" where Amy is the user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_email_subject">فقط جافا ل <xliff:g id="name" example="Amy">%s</xliff:g></string>

@ikenna8317
Copy link

To speed up production it's best to rely on google translate

@sheikhrasik
Copy link

" I'm not able to display Name, Price, Quantity & Toppings Chosen in the email intent. Please help. "

package com.example.android.justjava;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;

import java.text.NumberFormat;

/**

  • This app displays an order form to order coffee.
    */
    public class MainActivity extends AppCompatActivity {

    int quantity = 0;

    @OverRide
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    }

    public void increment(View view){
    quantity = quantity+1;
    displayQuantity(quantity);
    }

    public void decrement(View view){
    quantity = quantity-1;
    displayQuantity(quantity);
    }

    /**

    • This method is called when the order button is clicked.
      */
      public void submitOrder(View view) {
      CheckBox whippedCreamCheckBox = (CheckBox) findViewById(R.id.whipped_cream_checkbox);
      boolean hasWhippedCream = whippedCreamCheckBox.isChecked();

      CheckBox chocolateCheckBox = (CheckBox) findViewById(R.id.chocolate_checkbox);
      boolean hasChocolate = chocolateCheckBox.isChecked();

      EditText userName = (EditText) findViewById(R.id.name_field);
      String isName = userName.getText().toString() ;

      int price = calculatePrice(hasWhippedCream , hasChocolate);
      String priceMessage = createOrderSummary(price , hasWhippedCream , hasChocolate, isName);

      Intent intent = new Intent(Intent.ACTION_SENDTO);
      intent.setData(Uri.parse("mailto:")); // only email apps should handle this
      intent.putExtra(Intent.EXTRA_SUBJECT, "Just Java order for " + isName);
      intent.putExtra(Intent.EXTRA_TEXT, priceMessage);
      if (intent.resolveActivity(getPackageManager()) != null) {
      startActivity(intent);
      }
      // displayMessage(priceMessage);
      }

    /**

    • Calculates the price of the order

    • @param hasWhippedCream if user has whipper cream toppings

    • @param hasChocolate if user has chocolate toppings

    • @return total price
      */
      private int calculatePrice(boolean hasWhippedCream , boolean hasChocolate){
      // base price for one coffee cup
      int basePrice = 5;
      // user choose whipped cream topping
      if (hasWhippedCream)
      basePrice = basePrice +1;
      // user choose chocolate topping
      if(hasChocolate)
      basePrice = basePrice +2;

      return quantity * basePrice;

    }

    /**

    • Create summary of the order
    • @param name of the customer
    • @param price of the order
    • @param addWhippedCream is whether a user wants the whipped cream or not
    • @param addChocolate is whether a user wants the chocolate or not
    • @return text summary
      /
      private String createOrderSummary(int price , boolean addWhippedCream, boolean addChocolate , String name){
      String priceMessage = "\n" + getString(R.string.order_summary_name , name);
      priceMessage = "\n" + getString(R.string.order_summary_whipped_cream, addWhippedCream);
      priceMessage = "\n" + getString(R.string.order_summary_chocolate , addChocolate);
      priceMessage = "\n" + getString(R.string.order_summary_quantity , quantity);
      priceMessage = "\n" + getString(R.string.order_summary_price, NumberFormat.getCurrencyInstance().format(price));
      priceMessage ="\n" + getString(R.string.thank_you);
      return priceMessage;
      }
      /
      *
    • This method displays the given quantity value on the screen.
      */
      private void displayQuantity(int numb) {
      TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
      quantityTextView.setText("" + numb);
      }

@slavcok
Copy link

slavcok commented Nov 24, 2019

Slovak

values\string.xml

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="app_name">Just java</string>
    <string name="toppings">Toppings</string>
    <string name="name">Name </string>
    <string name="Whippedcream">Whipped cream </string>
    <string name="Chocolate">Chocolate </string>
    <string name="Quantity">Quantity </string>
    <string name="plus">plus </string>
    <string name="minus">minus </string>
    <string name="Ordersummary">Order summary</string>
    <string name="Order">Order </string>
    <string name="order_summary_name">Name:  <xliff:g id="name" example="Amy">%s</xliff:g></string>
    <string name="order_summary_whipped_cream">Whipped cream? <xliff:g id="addWhippedCream" example="true">%b</xliff:g></string>
    <string name="order_summary_chocolate">Chocolade? <xliff:g id="addChocolate" example="true">%b</xliff:g></string>
    <string name="order_summary_quantity">Quantity  <xliff:g id="quantity" example="2">%d</xliff:g></string>
    <string name="order_summary_price">Total: <xliff:g id="price" example="$10">%s</xliff:g></string>
    <string name="thank_you">Thanks you !</string>
</resources>

sk\string.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="app_name">Just java</string>
    <string name="thank_you">Ďakujem</string>
    <string name="toppings">Polevy</string>
    <string name="Chocolate">Čokoláda</string>
    <string name="Quantity">Počet</string>
    <string name="Whippedcream">Šľahačka</string>
    <string name="minus">mínus</string>
    <string name="name">"Meno "</string>
    <string name="plus">plus</string>
    <string name="order_summary_name">Meno <xliff:g id="name" example="Amy">%s</xliff:g></string>
    <string name="Ordersummary">Sumár objednávky</string>
    <string name="Order">Objednať</string>
    <string name="order_summary_price">Spolu <xliff:g id="price" example="$10">%s</xliff:g></string>
    <string name="order_summary_quantity">Množstvo <xliff:g id="quantity" example="2">%d</xliff:g></string>
    <string name="order_summary_whipped_cream">"Šľahačku ? "<xliff:g id="addWhippedCream" example="true">%b</xliff:g></string>
    <string name="order_summary_chocolate">Čokoládu ?<xliff:g id="addChocolate" example="true">%b</xliff:g></string>
</resources>

@ElikplimSunu
Copy link

Mine doesn't and never works. There's always a lot of error messages and... Man I'm sad right now, I need to understand how this works :(

@Sardorbekcyber
Copy link

  • Oʻzbek
  • <string name="app_name">Shunchaki Java</string>
    
  • <string name="chocolate">Shokoladli</string>
    
  • <string name="initial_quantity_value">2</string>
    
  • <string name="name">Ism</string>
    
  • <string name="order">Buyurtma</string>
    
  • <string name="order_summary_chocolate">Shokolad qoʻshilsinmi? <xliff:g id="addChocolate" example="true">%b</xliff:g></string>
    
  • <string name="order_summary_email_subject">Shunchaki javadan <xliff:g id="name" example="Amy">%s</xliff:g> buyurtma</string>
    
  • <string name="order_summary_name">Ism: <xliff:g id="name" example="Amy">%s</xliff:g></string>
    
  • <string name="order_summary_price">Jami: <xliff:g id="price" example="$10">%s</xliff:g></string>
    
  • <string name="order_summary_quantity">Miqdori: <xliff:g id="quantity" example="2">%d</xliff:g></string>
    
  • <string name="order_summary_whipped_cream"> Qaymoq qoʻshilsinmi? <xliff:g id="addWhippedCream" example="true">%b</xliff:g></string>
    
  • <string name="quantity">Miqdori</string>
    
  • <string name="thank_you">Rahmat!</string>
    
  • <string name="toppings">Qoʻshimchalar</string>
    
  • <string name="whipped_cream">Qaymoq</string>
    

@zufa1984
Copy link

zufa1984 commented May 1, 2020

Uzbek

Shunchaki Java
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="name">ism</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">qo\'shimchalar</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="whipped_cream">ko\'pirtirilgan qaymoq</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="chocolate">Shokolad</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="quantity">Soni</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=5] -->
<string name="initial_quantity_value">1</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="order">Buyurtma</string>

<!--
   Name for the order summary. It will be shown in the format of "Name: Amy" where Amy is the
   user's name. [CHAR LIMIT=NONE] -
    Эътибор беринг қуйидаги сатр мисол тариқасида бошқа йўл билан белгиланди. Буни афзаллик томони агарда таржимонлар мазкур сатрни боқа тилга таржима қилиши натижасида исмдан кейин сатр номи
    чиқиши керак бўлса яъни,"Amy:Name" чиқарилиши керак бўлса ":Name" сўзини исм қийматидан кейин ёзиши мумкин.

 -->
<string name="order_summary_name">Ism: <xliff:g id="customer" example="Amy">%s</xliff:g></string>

<string name="order_summary_whipped_cream">ko\'pirtirilgan qaymoq qo\'shish? <xliff:g id="cream" example="true">%s</xliff:g></string>

<string name="order_summary_chocolate">Shokolad qo\'shish? <xliff:g id="choco" example="true">%s</xliff:g></string>

<string name="quantity_coffee">Soni: <xliff:g id="quantity" example="1">%d</xliff:g></string>

<string name="total_price">Jami: <xliff:g id="price" example="5">%d</xliff:g>$</string>

<string name="thank_you">Raxmat!</string>

<string name="can_not_have_more100">Siz 100 donadan ortiq qaxva sotib ololmaysiz</string>

<string name="can_not_have_less1">Siz 1 donadan kam qaxva sotib ololmaysiz</string>

<string name="yesCream">ha</string>

<string name="noCream">yo\'q</string>

<string name="yesChoco">ha</string>

<string name="noChoco">yo\'q</string>

<string name="order_for"><xliff:g id="name" example="order for">%s</xliff:g> uchun Shunchaki Javadan buyurtma</string>

@zufa1984
Copy link

zufa1984 commented May 1, 2020

public class MainActivity extends AppCompatActivity {
int quantity = 1;
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void submitOrder(View view) {
CheckBox whippedCreamCheckbox = (CheckBox) findViewById(R.id.cream_checkbox);
boolean hasWhippedCream = whippedCreamCheckbox.isChecked();
CheckBox ChocolateCheckbox = (CheckBox) findViewById(R.id.chokolate_checkbox);
boolean hasChocolate = ChocolateCheckbox.isChecked();
EditText customerName = (EditText) findViewById(R.id.name_field);
String name = customerName.getText().toString();
int price = calculatePrice(hasWhippedCream, hasChocolate);
String priceMessage = createOrderSummary(price, hasWhippedCream, hasChocolate, name);
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.order_for, name) );
intent.putExtra(Intent.EXTRA_TEXT, priceMessage);
startActivity(intent);
}

private int calculatePrice(boolean addWhipperCream, boolean addChocolate) {
    int basePrice = 5;
    if (addWhipperCream) {
        basePrice += 1;
    }
    if (addChocolate) {
        basePrice += 2;
    }
    return quantity * basePrice;
}

private String createOrderSummary(int price, boolean cream, boolean choco, String customer) {
    String priceMessage = getString(R.string.order_summary_name,customer) ;
    String creamTopping ;
    String chocoTopping ;

    if (cream) {
        creamTopping = getString(R.string.yesCream);
    } else creamTopping = getString(R.string.noCream);

    if (choco) {
        chocoTopping = getString(R.string.yesChoco);
    } else chocoTopping = getString(R.string.noChoco);

    priceMessage += "\n" + getString(R.string.order_summary_whipped_cream, creamTopping) ;
    priceMessage += "\n" + getString(R.string.order_summary_chocolate, chocoTopping);
    priceMessage += "\n" + getString(R.string.quantity_coffee,quantity);
    priceMessage += "\n" + getString(R.string.total_price, price);
    priceMessage += "\n" + getString(R.string.thank_you);
    return priceMessage;
}

public void increment(View view) {
    if (quantity == 100) {
              Toast toast = Toast.makeText(this, getString(R.string.can_not_have_more100), Toast.LENGTH_LONG);
        toast.show();
                return;
    }
    quantity = quantity + 1;
    displayQuantity(quantity);
}

   public void decrement(View view) {
    if (quantity == 1) {
          Toast toast = Toast.makeText(this, getString(R.string.can_not_have_less1), Toast.LENGTH_LONG);
        toast.show();
                return;
    }
    quantity = quantity - 1;
    displayQuantity(quantity);
}
private void displayQuantity(int number) {
    TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
    quantityTextView.setText("" + number);
}
 private void displayPrice(String message) {
 TextView priceTextView = (TextView) findViewById(R.id.price_text_view);
 priceTextView.setText(message);
 }

}

@Naruto-uchiha24
Copy link

Can anyone help me....untill Intent everything was right but after localization neither subject is shown in gmail app nor order summsry shows correctly!!.......i have added screenshotnof emulator"s output too..

xml file*

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <EditText
        android:id="@+id/name_field"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Name"
        android:inputType="textCapWords"/>


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:layout_marginBottom="16dp"
        android:text="@string/toppings"
        android:textAllCaps="true" />

    <CheckBox
        android:id="@+id/whipped_cream_checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="24dp"
        android:text="@string/whipped_cream"
        android:textSize="16sp"/>

    <CheckBox
        android:id="@+id/chocolate_checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="24dp"
        android:text="@string/chocolate"
        android:textSize="16sp"/>




    <TextView

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:text="@string/quantity"
        android:textAllCaps="true" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:onClick="decrement"
            android:text="-" />


        <TextView
            android:id="@+id/quantity_text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="8dp"
            android:paddingRight="8dp"
            android:text="2"
            android:textSize="16sp" />
        <Button
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:onClick="increment"
            android:text="+" />




    </LinearLayout>


    <!--just comment out next two text views to exclude order summary from the app when it:s intented in email app


    <TextView

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:text="Order Summary"
        android:textAllCaps="true" />

    <TextView
        android:id="@+id/order_summary_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="$0"
        android:textSize="16sp" />
    -->


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:onClick="submitOrder"
        android:text="@string/order" />

</LinearLayout>

java fileeeeeeeee

package com.example.android.justjava;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import java.text.NumberFormat;

import androidx.appcompat.app.AppCompatActivity;

/**

This app displays an order form to order coffee.
*/
public class MainActivity extends AppCompatActivity {

int quantity =2;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
/**

 This method is called when the order button is clicked.
 */
public void increment(View view) {



    if (quantity == 100) {
        // show an error message as toast
        Toast.makeText(this, " You cannot have more than 100 coffee", Toast.LENGTH_SHORT).show();
        //exit this methold early because there is nothing left to do
        return;
    }
    quantity = quantity + 1;
    displayQuantity(quantity);
}
/**

 This method is called when the order button is clicked.
 */
public void decrement(View view) {



    if (quantity == 1) {
        // show an error message as toast
        Toast.makeText(this, " You cannot have less than 1 coffee", Toast.LENGTH_SHORT).show();
        //exit this methold early because there is nothing left to do
        return;
    }
    quantity = quantity - 1;
    displayQuantity(quantity);
}

/**

 This method is called when the order button is clicked.
 */
public void submitOrder(View view) {
    EditText nameField = (EditText) findViewById(R.id.name_field);
    //chain methold, namefield.getText gives Editable in output which then gives strings with toString methold on it
    String name = nameField.getText().toString();



    //figure out if user wants whipped cream topping
    CheckBox whippedCreamCheckBox = (CheckBox) findViewById(R.id.whipped_cream_checkbox);
    boolean hasWhippedCream = whippedCreamCheckBox.isChecked();

    //figure out if user wants chocolate topping
    CheckBox ChocolateCheckBox = (CheckBox) findViewById(R.id.chocolate_checkbox);
    boolean hasChocolate = ChocolateCheckBox.isChecked();



    int price = calculatePrice(hasWhippedCream,hasChocolate);
    String priceMessage = createOrderSummary(name, price, hasWhippedCream, hasChocolate);


    //use of intent for sending it to email app,where EXTRA_SUBJECT is for the subject in email app and EXTRA_TEXT is for the body of the email app
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:")); // only email apps should handle this
    intent.putExtra(Intent.EXTRA_SUBJECT,getString(R.string.order_summary_email_subject, name));
    //here EXTRA_TEXT is for BODY of the email app wheras EXTRA_SUBJECT is for subject part of email app
    intent.putExtra(Intent.EXTRA_TEXT, priceMessage) ;

    //preventing app from crashing in case there is no app supported for that function
    if (intent.resolveActivity(getPackageManager())!= null) {
        startActivity(intent);

    }

// now we don't have to display message in the app since, we are using intent

// displayMessage(priceMessage);

}



/**
 * Calculates the price of the order
 * @param addwhippedcream is whether or not the user wants whipped cream topping
 * @param addchocolate is whether or not user wants chocolate topping
 * @return total price
 */
private int calculatePrice(boolean addwhippedcream, boolean addchocolate) {
    // price of one cup of coffee
    int basePrice = 5;

    //add 1$ if user wants whipped cream toppings
    if (addwhippedcream){
        basePrice = basePrice +1;

    }

    //add 2$ if user wants chocolate toppings
    if  (addchocolate){
        basePrice = basePrice + 2;
    }

    //calculate the total price by multipling it to the quantity
    return quantity * basePrice;

}
 /*creat summary of order
 @param price of order
 @return text summary
  */
 private String createOrderSummary(String name,int price, boolean addWhippedCream, boolean addChocolate){
     String priceMessage = getString(R.string.order_summary_name, name);
     priceMessage+= "\n" + getString(R.string.order_summary_whipped_cream, addWhippedCream);
     priceMessage+= "\n" + getString(R.string.order_summary_chocolate, addChocolate);
     priceMessage =  "\n" + getString(R.string.order_summary_quantity, quantity);
     priceMessage =  "\n" + getString(R.string.order_summary_price,NumberFormat.getCurrencyInstance().format(price));
     priceMessage += "\n" + getString (R.string.thank_you);
     return priceMessage;
}



/**

 This method displays the given quantity value on the screen.
 */
private void displayQuantity(int numberOfCoffees) {
    TextView quantityTextView = (TextView) findViewById(
            R.id.quantity_text_view);
    quantityTextView.setText("" + numberOfCoffees);
}

/**
* This method displays the given text on the screen,but now we don't want to show order summary since we already are parsinf it to the email app through intent
*/
// private void displayMessage(String message) {
// TextView OrderSummaryTextView = (TextView) findViewById(R.id.order_summary_text_view);
// OrderSummaryTextView.setText(message);
// }
}

**string(english version)

just Java
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="name">Name</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">Toppings</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="whipped_cream">Whipped cream</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="chocolate">Chocolate</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="quantity">Quantity</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=5] -->
<string name="initial_quantity_value">2</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="order">Order</string>

<!--
  Name for the order summary. It will be shown in the format of "Name: Amy" where Amy is the
  user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_name">Name: <xliff:g id="name" example="Amy">%s</xliff:g></string>

<!--
  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="addWhippedCream" 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="addChocolate" example="true">%b</xliff:g></string>

<!--
  Quantity of coffee cups for the order summary. It will be shown in the format of
  "Quantity: 2", where 2 is the number of cups ordered. [CHAR LIMIT=NONE]
-->
<string name="order_summary_quantity">Quantity: <xliff:g id="quantity" example="2">%d</xliff:g></string>

<!--
  Total price for the order summary. It will be shown in the format of
  "Total: $10" where $10 is the price. [CHAR LIMIT=NONE]
-->
<string name="order_summary_price">Total: <xliff:g id="price" example="$10">%s</xliff:g></string>

<!-- Thank you message for the order summary. [CHAR LIMIT=NONE] -->
<string name="thank_you">Thank you!</string>

<!--
  Subject line for the order summary email. It will be in the format of
  "Just Java order for Amy" where Amy is the user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_email_subject">Just Java order for <xliff:g id="name" example="Amy">%s</xliff:g></string>

string(spanish version****

Sólo Java
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="name">Nombre</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">Ingredientes</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="whipped_cream">Crema batida</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="chocolate">Chocolate</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="quantity">Cantidad</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=5] -->
<string name="initial_quantity_value">2</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="order">Ordenar</string>

<!--
  Name for the order summary. It will be shown in the format of "Name: Amy" where Amy is the
  user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_name">Nombre: <xliff:g id="name" example="Amy">%s</xliff:g></string>

<!--
  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">Agregue la crema batida? <xliff:g id="addWhippedCream" 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">Agregue el chocolate? <xliff:g id="addChocolate" example="true">%b</xliff:g></string>

<!--
  Quantity of coffee cups for the order summary. It will be shown in the format of
  "Quantity: 2", where 2 is the number of cups ordered. [CHAR LIMIT=NONE]
-->
<string name="order_summary_quantity">Cantidad: <xliff:g id="quantity" example="2">%d</xliff:g></string>

<!--
  Total price for the order summary. It will be shown in the format of
  "Total: $10" where $10 is the price. [CHAR LIMIT=NONE]
-->
<string name="order_summary_price">Total: <xliff:g id="price" example="$10">%s</xliff:g></string>

<!-- Thank you message for the order summary. [CHAR LIMIT=NONE] -->
<string name="thank_you">¡Gracias!</string>

<!--
  Subject line for the order summary email. It will be in the format of
  "Just Java order for Amy" where Amy is the user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_email_subject">Sólo java para <xliff:g id="name" example="Amy">%s</xliff:g></string>

@alvee-unb
Copy link

@Naruto-uchiha24 Are you still facing the same issue? Have you tried to keep logs where the intent was called from?

@SafiaBakour
Copy link

رغم اني املك تطبيق البريد الالكتروني في هاتفي لكن لم يستطع تطبيق جاست جافا استدعاءه لارسال ملخص الطلب
اعني انني عندما اضغط على زر الطلب لا يبعث الغرض للبريد الالكتروني
@RequiresApi(api = Build.VERSION_CODES.N)
public void submitOrder(View view) {
// Figure out if the user wants whipped cream topping
CheckBox WhippedCreamCheckBox = (CheckBox) findViewById(R.id.add_whipped_cream);
boolean hasWhippedCream = WhippedCreamCheckBox .isChecked();

    // Figure out if the user wants chocolate topping
   CheckBox  chocolateCheckBox= findViewById(R.id.chocolate_checkbox);
   boolean hasChocolate = chocolateCheckBox.isChecked();

   EditText nameField = findViewById(R.id.name_of_user);
  String name =nameField.getText().toString();

  int price = calculatePrice(hasWhippedCream,hasChocolate);
  String priceMessage = creatOrderSummary(price,hasWhippedCream, hasChocolate,name);


Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_SUBJECT,"Just java order for"+name);
intent.putExtra(Intent.EXTRA_TEXT,priceMessage);

 displayMessage(priceMessage);


 

}

وهدا هو الكود الخاص بالغرض ارجو المساعدة كي استطيع متابعة الدروس

@engsarahfouad
Copy link

Arabic Version
النسخة العربية

الجافا فقط

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="name">الأسم</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">إضافات</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="whipped_cream">كريمه</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="chocolate">شوكولاتة</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="quantity">الكميه</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=5] -->
<string name="initial_quantity_value">٢</string>

<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="order">أطلب</string>

<!--
  Name for the order summary. It will be shown in the format of "Name: Amy" where Amy is the
  user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_name">: الأسم<xliff:g id="name" example="Amy">%s</xliff:g></string>

<!--
  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">إضافة كريمه ؟ <xliff:g id="addWhippedCream" 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">إضافة شوكولاتة؟<xliff:g id="addChocolate" example="true">%b</xliff:g></string>

<!--
  Quantity of coffee cups for the order summary. It will be shown in the format of
  "Quantity: 2", where 2 is the number of cups ordered. [CHAR LIMIT=NONE]
-->
<string name="order_summary_quantity">: الكميه<xliff:g id="quantity" example="2">%d</xliff:g></string>

<!--
  Total price for the order summary. It will be shown in the format of
  "Total: $10" where $10 is the price. [CHAR LIMIT=NONE]
-->
<string name="order_summary_price">:الأجمالى <xliff:g id="price" example="$10">%s</xliff:g></string>

<!-- Thank you message for the order summary. [CHAR LIMIT=NONE] -->
<string name="thank_you">شكراَ</string>

<!--
  Subject line for the order summary email. It will be in the format of
  "Just Java order for Amy" where Amy is the user's name. [CHAR LIMIT=NONE]
-->
<string name="order_summary_email_subject"> الجافا فقط إلى <xliff:g id="name" example="Amy">%s</xliff:g></string>

السلام عليكم
ممكن توضيح لx liff ؟ للغة العربية

@mateendev3
Copy link

Turkish Translation

Sadece Java Topingler Teşekkürler Krem şanti Çikolata Miktar Emir İsim: %s Miktar: %s Çırpılmış krema ekler misiniz? %s Çikolata ekle?? %s Toplam: ₺%f İsim iki Sadece Java Siparişi

@rebeccazee
Copy link

For the strings that use booleans variables, I did two types of strings for the true and false. For order_summary_whipped_cream and order_summary_chocolate I got rid of the xliff:g and used this code:
English

<!--
    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_true">Add whipped cream? true</string>
<string name="order_summary_whipped_cream_false">Add whipped cream? false</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_true">Add chocolate? true</string>
<string name="order_summary_chocolate_false">Add chocolate? false</string>

`Spanish

<!--
    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_true">Agregue la crema batida? verdadero</string>
<string name="order_summary_whipped_cream_false">Agregue la crema batida? falso</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_true">Agregue el chocolate? verdadero</string>
<string name="order_summary_chocolate_false">Agregue el chocolate? falso</string>

Then in the java file, I used the conditional operator, ?:, to set the values.to the boolean variables.

@imohdalam
Copy link

imohdalam commented Feb 5, 2022

Hindi Version

 <?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="app_name">JavaActivity</string>
    <string name="chocolate">चॉकलेट</string>
    <string name="whipped_cream">मार पड़ी क्रीम</string>
    <string name="order">आदेश</string>
    <string name="toppings">सामग्री</string>
    <string name="order_summary">आदेश सारांश</string>
    <string name="quantity">"परिमाण: "</string>
    <string name="thank_you">धन्यवाद!!</string>
    <string name="Whipped_Cream">"व्हीप्ड क्रीम जोड़ें? "</string>
    <string name="Chocolate">"चॉकलेट जोड़ें? "</string>
    <string name="name_text">" नाम: <xliff:g example="Amy" id="name">%s</xliff:g>"</string>
    <string name="total">"कुल: "</string>
    <string name="name">नाम</string>
</resources>

@YazanMunirA
Copy link

اسم التطبيق الاضافات شكرا لكم معلومات الطلب اكمل $0 اضف كريمة ? %b أضف شكولاته؟ القيمه %d المجموع%s
<string name="order_summary_name"> الاسم<xliff:g id="quantity" example="Yazan">%s</xliff:g></string>

Java>>>>
package com.example.justjava;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

/**

  • This app displays an order form to order coffee.
    */
    public class MainActivity extends AppCompatActivity {
    int quantity;

    @OverRide
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    }
    /**

    • This method is called when the plus button is clicked. Intent intent = new Intent(Intent.ACTION_SENDTO);
    •     intent.setData(Uri.parse("mailto:")); // only email apps should handle this
      
    •     intent.putExtra(Intent.EXTRA_SUBJECT, "just jvaa" + editable);
      
    •     if (intent.resolveActivity(getPackageManager()) != null) {
      
    •         startActivity(intent);
      
    •     }
      

    */
    public void increment(View view) {

     if (quantity==15){
    
         Toast.makeText(this, " you cannot have more than 15  ", Toast.LENGTH_SHORT).show();
         return;
     }
     quantity=++quantity;
     displayQuantity(quantity);
    

    }
    /**

    • This method is called when the sub button is clicked.
      /
      public void decrement(View view) {
      if (quantity<1){
      Toast.makeText(this, "you cannot have less 1 cup", Toast.LENGTH_SHORT).show();
      return;
      }
      quantity=--quantity;
      displayQuantity(quantity);
      }
      /
      *

    • This method is called when the order button is clicked.
      */
      @SuppressLint("QueryPermissionsNeeded")
      public void submitOrder(View view) {
      EditText name = (EditText) findViewById(R.id.EditText_view);
      String Name = name.getText().toString(); // Editable Name = editText.getText();

      CheckBox isCheck = (CheckBox) findViewById(R.id.checkbox);
      boolean hasWhippedCream = isCheck.isChecked();

      CheckBox ischocolate = (CheckBox) findViewById(R.id.chocolate_checkbox);
      boolean hasChocolate = ischocolate.isChecked();

      int price = calculatePrice(hasWhippedCream, hasChocolate);
      String priceMassage = CsreateOrderSummary(price, hasWhippedCream, hasChocolate, Name);

      Intent intent = new Intent(Intent.ACTION_SENDTO);
      intent.setData(Uri.parse("mailto:")); // only email apps should handle this
      intent.putExtra(Intent.EXTRA_SUBJECT, "Just Java order for "+ Name);
      intent.putExtra(Intent.EXTRA_TEXT, priceMassage);
      startActivity(intent);

       displayMessage(priceMassage);
      

    }

    private void displayQuantity(int number) {
    TextView quantityTextView = findViewById(R.id.quantity_text_view); // num of cups
    quantityTextView.setText("" + number);
    }

    /**

    • This method displays the given text on the screen.
      */
      private void displayMessage(String message) {
      TextView priceTextView = (TextView) findViewById(R.id.summary_order_text_view); // string
      priceTextView.setText(message);
      }

    /**

    • Calculate thr taxes of Saudi Arabia \if (hasWhippedCream || hasChocolate){
    •         price = calculatePrice() + 5 ;
      
    •     } if (hasWhippedCream  && hasChocolate){
      
    •         price = calculatePrice() + 10;
      
    •     } else if(hasChocolate|| hasWhippedCream){
      
    •         Toast.makeText(this, "have you add Toppings ", Toast.LENGTH_SHORT).show();
      
    • @return the value of taxes
      /
      private int calculatePrice( boolean addWhippedCream ,boolean addChocolate ) {
      int price = 5;
      if (addWhippedCream){
      price = price +1; }
      if (addChocolate){
      price = price+2; }
      return quantity
      price;

    }
    /**
    * Create summary of the order.

  •   * @param name of the customer
    
  • @param price of the order

  • @param addWhippedCream is whether or not the user wants whipped cream topping

  • @param hasChoco is whether or not the user wants chocolate topping
    * @return text summary
    */
    private String CsreateOrderSummary (int price , boolean addWhippedCream,boolean hasChoco,String name ) {

     String priceMessage = getString(R.string.order_summary_name)+ name+":";
     priceMessage += "\n" +getString(R.string.add_whipped) + "?"+addWhippedCream;
     priceMessage += "\n"+getString(R.string.add_chocolat) + "?"+ hasChoco;
      priceMessage +=    quantity+"\n"+getString(R.string.quantity) ;
     priceMessage += "\n"+getString(R.string.Total) + price;
     priceMessage += "\n"+ getString(R.string.thank_you);
    
    
     return priceMessage;
    

    }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment