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.
It work for me
similar to the accepted answered but 2017 version and added restart (without restarting, sometimes the next Activity still renders English):
Here is some code that works for me:
Source: here
I was looking for a way to change the system language programmatically. While I fully understand that a normal application should never do that and instead either:
there was a need to really change the language of the system programmtically.
This is undocumented API and thus should not be used for market/end-user applications!
Anyway heres the solution i found:
According to this article. You will need to download
LocaleHelper.java
referenced in that article.MyApplication
class that will extendsApplication
attachBaseContext()
to update language.Register this class in manifest.
Create
BaseActivity
and overrideonAttach()
to update language. Needed for Android 6+Make all activities on your app extends from
BaseActivity
.I know it's late to answer but i found this article here . Which explains the whole process very well and provides you a well structured code.
Locale Helper class:
You need to override attachBaseContext and call LocaleHelper.onAttach() to initialize the locale settings in your application.
All you have to do is to add
wherever you want to change the locale.