On Mon, Jul 23, 2018 at 2:16 PM, Miro Hrončok <mhron...@redhat.com> wrote: > Currently, the documentation (as well as plenty of other places on the > Internet, such as Stack Overflow answers) mentions msgfmt.py and > pygettext.py. > > See https://docs.python.org/3/library/gettext.html > >> (Python also includes pure-Python versions of these programs, called >> pygettext.py and msgfmt.py; some Python distributions will install >> them for you. pygettext.py is similar to xgettext, but only >> understands Python source code and cannot handle other programming >> languages such as C or C++. pygettext.py supports a command-line >> interface similar to xgettext; for details on its use, run >> pygettext.py --help. msgfmt.py is binary compatible with GNU msgfmt. >> With these two programs, you may not need the GNU gettext package to >> internationalize your Python applications.) > > The problematic part is: "some Python distributions will install them for > you" > > As a Python distributor, I may ask myself a question: Where do I install > those? > > As a Python user, I may ask: Where did the distributors put them, and did > they? > > So I suggest we make those modules instead and we document how to use them.
Not completely "instead" perhaps; the original Tools/i18n/*.py scripts can be changed to just import the new module and call it. > It might be: > > $ python3 -m gettext +1 > And: > > $ python3 -m gettext.msgfmt +1 Note that this means gettext will need to become a package. > And (provided as a shortcut): > > $ python3 -m msgfmt -1. This would mean adding a new top-level module to the standard library. Let's not pollute that namespace just to provide a shortcut. > > I feel that using -m is the general direction Python is going, considering > this message: > > $ pyvenv ... > WARNING: the pyenv script is deprecated in favour of `python3.7 -m venv` > > It also gives the user a choice for Python version on a system with multiple > Python versions installed as the user could do: > > $ python3.6 -m gettext > > Or > > $ python3.7 -m gettext > > While with e.g. /usr/bin/pygettext.py this adds unnecessary burden on the > distributor to package /usr/bin/pygettext-3.7.py etc... Yes – pygettext depends on the Python version, so being able to do this sounds very useful. Less so for msgfmt of course. I'm adding Barry Warsaw, who originally wrote pygettext and AFAIK still does i18n in Python. Barry, does this sound reasonable to you? _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/