Blog purpose for android basic example for android app developer. any query please my contact

Sunday, 30 October 2022

Supporting Different Languages in android

 Supporting Different Languages in android


In this article, we will learn how to build an Android APP that supports (Internationalization and Localization) in multiple languages. Language plays a crucial role in the overall interface of the app and it is great if you can append more languages to it so that you can support a wider audience. This makes your Android app more usable and a larger audience can comfortably use it. 



Android is one of only a handful couple of well-known portable working frameworks having a great many clients in more than 190 nations and developing step by step. So when you are pointing your application to be all-inclusive effective, it is dependably a smart thought to make the application limited.



values-es>strings.xml

<resources>

    <string name="app_name">Multilingual App</string>

    <string name="thank_you">Gracias</string>

</resources>

values-hi>strings.xml

<resources>

    <string name="app_name">Multilingual App</string>

    <string name="thank_you">धन्यवाद</string>

</resources>



values-fr>strings.xml

<resources>

    <string name="app_name">Multilingual App</string>

    <string name="thank_you">Je vous remercie</string>

</resources>





activity_main.xml


<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent">

    <Spinner

        android:id="@+id/spinner"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        app:layout_constraintLeft_toLeftOf="parent"

        app:layout_constraintRight_toRightOf="parent"

        app:layout_constraintTop_toBottomOf="@+id/guidline" />


    <TextView

        android:id="@+id/string"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="@string/thank_you"

        android:textSize="25sp"

        app:layout_constraintBottom_toBottomOf="parent"

        app:layout_constraintLeft_toLeftOf="parent"

        app:layout_constraintRight_toRightOf="parent"

        app:layout_constraintTop_toTopOf="parent" />


    <android.support.constraint.Guideline

        android:id="@+id/guidline"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:orientation="horizontal"

        app:layout_constraintGuide_percent="0.26" />


</android.support.constraint.ConstraintLayout>


No comments:

Post a Comment