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