Support `locale` module on Android
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Migrated from https://github.com/chaquo/chaquopy/issues/1150:
From https://github.com/beeware/toga/discussions/2562:
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, probably because it supports changing the locale within the lifetime of a single process. Instead, it provides an Android-specific API:
context.getResources().getConfiguration().getLocales().get(0)
This will return a string in the form en_US, which can be passed to locale.setlocale.
The difficult part is getting a reference to the context object. For details, see https://github.com/python/cpython/issues/90371#issuecomment-2991401118.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Python locale module and the Android context guidance linked in the issue; no specific file or test is named. Determine how to access Android's current locale and verify that locale.getlocale() reflects it instead of always returning en_US, while remaining compatible with locale.setlocale.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, python
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100