Support `locale` module on Android
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
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.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Python 的 locale 模組以及 issue 中連結的 Android context 指南開始;沒有指定具體檔案或測試。確定如何存取 Android 目前的 locale,並驗證 locale.getlocale() 會反映該 locale,而不是一律回傳 en_US,同時維持與 locale.setlocale 的相容性。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- android, python
- 領域
- mobile-dev
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100