I set my android app local via
fun setSystemLocale(context: Context): Context {
val locale = getCurrentLanguage().locale
Locale.setDefault(locale)
val configuration = Configuration(context.resources.configuration)
configuration.setLocale(locale)
configuration.setLayoutDirection(locale)
context.resources.updateConfiguration(configuration, context.resources.displayMetrics)
return context.createConfigurationContext(configuration)
}
set app local work fine on lower versions(Below Android 13) but, on Android 13 & 14 Sometimes language change partially or sometimes language change does not reflect.
2
Answers
my app has a function to change in-app language too.
But, I had a same problem in my language picker.
Sometimes language is changed partially in Android 13 & 14.
I could find a solution in android’s developer doc.
https://developer.android.com/guide/topics/resources/app-languages?hl=en#kotlin
Here is a sample code.
If you want to use this solution, your appcompat version must be 1.6.0 or higher.
I hope it works out.
The provided code snippet addresses a potential cause of missing language resources in your app built using Android App Bundles (AAB) for Play Store publishing. Here’s a breakdown of the code and its implications:
Code Explanation:
Gradle