sofs1
sofs1

Reputation: 4176

How should my android app change its language, when user changes mobile phone language?

Within my app, I let user change the language when they install the app. Lets say they choose "English" while installing the app. But after that if they change the language of the phone to "French" how should my app receive it and change its language?

Upvotes: 0

Views: 89

Answers (3)

Pavul Zavala
Pavul Zavala

Reputation: 425

Assuming you use strings.xml to manage your string resources, Android natively supports localization: https://developer.android.com/preview/features/multilingual-support.html

The idea is that you have distinct strings and values for each language you want to manage, then when the user changes the language in settings the app will automatically choose the correct file (or fall back to the default strings.xml if you haven't defined resources for the chosen language).

Upvotes: 1

user5386763
user5386763

Reputation:

It will try to get information about french in values (value-fr) if you didnt add the translations it will keep showing english

Upvotes: 0

Clark Wilson
Clark Wilson

Reputation: 389

The app will automatically load its respective language strings files from the res/values directory after the application restarts. You could persist and compare Locale.getDefault().getLanguage() to check if the language has changed since the last restart.

Upvotes: 0

Related Questions