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 lan
https://stackoverflow.com/a/48531811/9609776
This is ok but do not split the updateResources into different versions, just use the solution below (kotlin). Key is in "Configuration(context.resources.configuration)" it makes deep copy.
100% solution for API 21+. I have not tested for lower ones, but should work.
private fun updateResources(context: Context, language: String): Context {
return Configuration(context.resources.configuration).run {
Locale.setDefault(Locale(language).also { locale ->
setLocale(locale)
}).let {
context.createConfigurationContext(this)
}
}
}