Reputation: 4176
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
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
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
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