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.
I was facing the same issue. On GitHub I found the Android-LocalizationActivity library.
This library makes it very simple to change the language of your app at runtime, as you can see in the code sample below. A sample project including the sample code below and more information can be found at the github page.
The LocalizationActivity extends AppCompatActivity, so you can also use it when you are using Fragments.
I am changed for German language for my app start itself.
Here is my correct code. Anyone want use this same for me.. (How to change language in android programmatically)
my code:
It's possible. You can set the locale. However, I would not recommend that. We've tried it at early stages, it's basically fighting the system.
We have the same requirement for changing the language but decided to settle to the fact that UI should be same as phone UI. It was working via setting locale but was too buggy. And you have to set it every time you enter activity (each activity) from my experience. here is a code if you still need this (again, I don't recommend that)
If you have language specific content - you can change that base on the setting.
If you want to mantain the language changed over all your app you have to do two things.
First, create a base Activity and make all your activities extend from this:
Note that I save the new language in a sharedPreference.
Second, create an extension of Application like this:
Note that getLocale() it's the same as above.
That's all! I hope this can help somebody.
This is working when i press button to change text language of my TextView.(strings.xml in values-de folder)
Take note that this solution using
updateConfiguration
will not be working anymore with the Android M release coming in a few weeks. The new way to do this is now using theapplyOverrideConfiguration
method fromContextThemeWrapper
see API docYou can find my full solution here since I faced the problem myself: https://stackoverflow.com/a/31787201/2776572