You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, how can I recognize the current language with locale.getlocale()?
When i try it on android, it only returns ('en_US', 'UTF-8'), even if default language was set to an other language.
I don't think Android sets any of the standard LC_... environment variables, but we can get this information from the Android API:
# In a Toga app, the equivalent of `context` is `app._impl.native`, # where `app` is your `toga.App` object.str(context.getResources().getConfiguration().getLocales().get(0))
This will return a string in the form en_US, which can be passed to locale.setlocale.
The text was updated successfully, but these errors were encountered:
Is this not something that could/should be upstreamed into CPython itself? Or is this a case where because the usual C API isn't honored, fixing it would require the use of a Java API, would require either CPython to adopt Chaquopy (or another JNI wrapper), or the implementation of locale to replicate enough raw JNI handling to satisfy the API call?
There's a broad analog of this with the iOS implementation of webbrowser - that code does the bare minimum ctypes invocation to call the native Objective C API to launch the browser. Would something analogous to that be possible for Android (both for webbrowser, and for locale?)
At the very least, it seems like there should be a note in the CPython docs that locale has limitations on Android.
From beeware/toga#2562:
I don't think Android sets any of the standard
LC_...
environment variables, but we can get this information from the Android API:This will return a string in the form
en_US
, which can be passed tolocale.setlocale
.The text was updated successfully, but these errors were encountered: