Make the gettext functions accept a localedir of type Traversable
未关闭
还没有人认领这个 Issue。
stdlib
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Feature or enhancement
Proposal:
from gettext import bindtextdomain, find, translation
import importlib.resources
bindtextdomain("demo-zipapp", importlib.resources.files("demo_zipapp").joinpath("locales"))
translation("demo-zipapp", importlib.resources.files("demo_zipapp").joinpath("locales"))
find("demo-zipapp", importlib.resources.files("demo_zipapp").joinpath("locales"))
In ZipApp, since files within the application cannot be read directly through traditional file APIs, it is necessary to use importlib.resources.files to read them.
importlib.resources.files returns a Traversable object, which is not supported by gettext.
Here is a demo app: demo-zipapp.zip (source) | demo-zipapp.zip (zipapp)
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
Linked PRs
- gh-149810
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 gettext.bindtextdomain、gettext.translation 和 gettext.find 这些入口点开始,然后查看关联的 PR gh-149810 以及所引用的 Discourse 讨论。当这些函数能够接受用于 ZipApp 内资源的 Traversable localedir,并且对所演示用法有覆盖时,此更改即完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- internationalization
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100