Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale not working proper in Android 11 and Android 12 #52

Open
yahya-ebizz opened this issue Jul 8, 2022 · 7 comments
Open

Locale not working proper in Android 11 and Android 12 #52

yahya-ebizz opened this issue Jul 8, 2022 · 7 comments

Comments

@yahya-ebizz
Copy link

No description provided.

@YarikSOffice
Copy link
Owner

Hey @yahya-ebizz

Could you please share more details on what is wrong with Android 11 and 12?

I've tested the sample app using the latest versions, but I haven't come across any issues.

@zeroDivider
Copy link

I spotted it is not working on Android 13 ether. It is translating half of the app, also changing language 2 or more times when app is active is especially critical..

@ahmed-elkhadragy
Copy link

the library works great on Android 10, but when tested on Android 12 I found that words do translate to the right language but layout don't change direction ltr to rtl and vise versa

@YarikSOffice
Copy link
Owner

@zeroDivider @ahmed-elkhadragy Trying to figure out what is the cause of your issue with new android versions

  1. Do you restart your activity/app once the new locale is applied?
  2. Do you use the navigation component/fragments for your screens?

@ahmed-elkhadragy
Copy link

@zeroDivider @ahmed-elkhadragy Trying to figure out what is the cause of your issue with new android versions

  1. Do you restart your activity/app once the new locale is applied?
  2. Do you use the navigation component/fragments for your screens?

Hello, yes I used receeate() to restart the activity and it indded changes language but it's all about layout direction and I don't use navigation component nor fragment my app is single screen single activity app..
I turned around the issue right now until it's figured out by making the locale change in different activity and reopening the original activity and it works fine but my original plan was to change locale from the same screen/activity

@AlexeyGodyaev
Copy link

AlexeyGodyaev commented Sep 5, 2023

reason:
IME_AUTOFILL_DEFAULT_SUPPORTED_LOCALES_IS_EMPTY
Change ID: 169273070
Default State: Enabled for apps that target Android 12 (API level 31) or higher.
For apps targeting Android 12 (API level 31) and higher, getSupportedLocales() now returns an empty locale list when it's not set, instead of the default system locale.

PS: Just passing by, due to an attempt to migrate from Sharedpreferences to DataStore

@AlexeyGodyaev
Copy link

My option
fun Configuration.getFirstLocale(): Locale =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
getSystemLocale()
} else {
val locales = ConfigurationCompat.getLocales(this)
if (locales.isEmpty) localeENGLISH
else (locales[0] ?: localeENGLISH)
}

fun getSystemLocale(): Locale = getSystemLocales().get(0) ?: Locale.getDefault()
fun getSystemLocales(): LocaleListCompat =
ConfigurationCompat.getLocales(Resources.getSystem().configuration)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants