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:
https://discuss.python.org/t/make-the-gettext-functions-accept-a-localedir-of-type-traversable/107330
Linked PRs
Feature or enhancement
Proposal:
In ZipApp, since files within the application cannot be read directly through traditional file APIs, it is necessary to use
importlib.resources.filesto read them.importlib.resources.filesreturns aTraversableobject, 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:
https://discuss.python.org/t/make-the-gettext-functions-accept-a-localedir-of-type-traversable/107330
Linked PRs