Make the gettext functions accept a localedir of type Traversable
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
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 gettext.bindtextdomain, gettext.translation, and gettext.find entry points, then review linked PR gh-149810 and the referenced Discourse discussion. The change is complete when these functions accept a Traversable localedir for resources inside a ZipApp, with coverage for the demonstrated usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- internationalization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100