Is it possible to change the language of an app programmatically while still using Android resources?
If not, is it possible to request a resource in an specific language?
I would like to let the user change the language of the app from the app.
Is it possible to change the language of an app programmatically while still using Android resources?
If not, is it possible to request a resource in an specific language?
I would like to let the user change the language of the app from the app.
There are some steps that you should implement
First, you need to change the locale of your configuration
Second, if you want your changes to apply directly to the layout that is visible, you either can update the views directly or you can just call activity.recreate() to restart the current activity.
And also you have to persist your changes because after user closes your application then you would lose the language change.
I explained more detailed solution on my blog post Change Language Programmatically in Android
Basically, you just call LocaleHelper.onCreate() on your application class and if you want to change locale on the fly you can call LocaleHelper.setLocale()
Just adding an extra piece that tripped me up.
While the other answers work fine with "de" for example
The above wont work with for example
"fr_BE"
locale so it would use thevalues-fr-rBE
folder or similar.Needs the following slight change to work with
"fr_BE"
First you create directory name values-"Language name" like hindi than write "hi" and same string file name copy in this directory and change value do not change parameter after set below code in your action like button etc....
Just handle in method
Follow the Link
I think it is useful
At first create multi string.xml for different languages; then use this block of code in
onCreate()
method:In example we set English language:
Please, remember this works only if language is found in Device system also, not only in application