Per App language android - android 13 . Context - getString

85 Views Asked by At

val context = appContext

context.getString(key) is returning string in default language of system in android 12 , while it is returning string in selected language in android 13. Is there any alternative method to support for both. Needed string in the selected language

1

There are 1 best solutions below

0
Mohsen On

It's a reported issue with Per App Language. This is the suggested workaround. https://developer.android.com/reference/androidx/core/content/ContextCompat#getContextForLanguage(android.content.Context)

Use:

ContextCompat.getContextForLanguage(context).getString(R.string.myString)

instead of:

context.getString(R.string.myString)