

Posted via Neelansh Sahai Android Developer Members of the family Engineer (on Twitter and LinkedIn)What you probably have a suite of customers who’re somewhat fluent in English, Hindi, and Spanish, and they have got a information app on their telephones and like to learn the scoop in Hindi? For his or her texting app, they like Spanish as they have got some family and friends who they textual content with in Spanish. However for ease of get entry to, they nonetheless favor their software to be in English. Now there are lots of such use-cases the place the customers may need their app languages to be other from their gadget language. Attention-grabbing!
![]() |
Construct to your multilingual customers
This weblog specializes in easy methods to combine the In step with-App Language Personal tastes API for your app to supply your customers the versatility to make a choice other languages for various apps.
1. Customers can trade the language settings from gadget settings via settling on:
Settings → Device → Languages & Enter → App Languages → [Select the desired App] → [Select the desired Language]
2. In case your app already has an in-app language picker, you’ll be able to combine the In step with-App Language Personal tastes API to leverage the total platform reinforce. For pre-Android 13 customers, the gadget settings gained’t be visual, however builders can nonetheless supply an in-app language picker.
combine this selection for your app?
There are 5 steps that want to be adopted whilst running at the In step with-App Language Personal tastes characteristic, indexed right here →
1. Create locale_config.xml report
Create a brand new report in values/xml/ listing and identify it as locale_config.xml. This report will have to comprise a listing of the entire locales which might be supported via the app. The record component will have to be a string containing a locale tag.
locale_config.xml
2. Upload the locale_config within the AndroidManifest.xml
Specify this locale_config.xml report within the app’s AndroidManifest.xml
AndroidManifest.xml
After steps 1 & 2, your customers will have the ability to uncover and set their language choice to your app from gadget settings on units working Android 13 or upper. If your customers are on units working on variations less than Android 13, you’ll be able to supply an in-app language picker. Optionally, you’ll be able to additionally come with the similar language picker for your app for units working Android 13 or upper. When your app comprises an in-app language picker, it is necessary for the person’s personal tastes to be in sync between the gadget and the app. That is the place the AndroidX APIs come into the image. Learn directly to discover ways to create an in-app language picker.
Use the most recent model of AppCompat Library
4. Use AndroidX APIs
Use the APIs for your code to set and get the app locales.
MainActivity.kt
5. Delegate garage to AndroidX
Let AndroidX deal with the locale garage in order that the person’s choice persists.
AndroidManifest.xml
Steps 3, 4, & 5 above exhibit the minimal parts had to create an in-app language picker.
And with this, your app can now reinforce locale switching.
Further issues to maintain whilst migrating to the API
Previous, builders needed to deal with the person’s personal tastes on their very own, both via the use of SharedPreferences, storing the information on a server, or different app good judgment. With the new APIs, there is not any want to deal with this one at a time. So if you find yourself the use of those APIs, AndroidX is already caring for the garage section, however what occurs when the app is opened for the primary time after a person updates their software to Android 13 or upper?
On this case, the gadget gained’t take note of the person’s personal tastes for the app language and thus it’ll map the app to the default gadget language. To steer clear of this, builders want to upload some one-time migration good judgment in order that their customers don’t must set the language once more after they replace the app.
What flexibility does the characteristic supply to the customers and builders?
Right here are some things that may end up to be really helpful for you customers.
- All units working Android 13 or upper may have a commonplace position for customers to find and alter the language in their apps.
- Despite the fact that the gadget settings are restricted to the units working Android 13 or upper, the AndroidX APIs are backwards appropriate. Thus, there is not any requirement so as to add OS Model assessments for your code whilst construction to your multilingual customers.
- Builders don’t want to deal with configuration adjustments one at a time or concern about storing the person’s decided on language each time. The API handles configuration adjustments and retail outlets the language personal tastes for you.
- Works with different Android options like Backup and repair. If a person switches to a brand new software and restores the in the past sponsored up information, your app will retain the person’s final most well-liked language, thus offering your customers with a greater and extra seamless enjoy.
Recap
With that, maximum portions of the characteristic are lined. So let’s have a handy guide a rough recap on what we mentioned in lately’s learn.
- A snappy learn on what In step with-App Language Personal tastes be offering to multilingual customers and app builders.
- What finish customers will see on their units.
- migrate your app to the In step with-App Language Personal tastes APIs.
- A couple of issues that want to be looked after whilst migrating to the APIs to verify a greater person enjoy.
- Finally, the advantages that finish customers and builders can leverage from this selection.