How to localize Python's argparse module, without patching it?

匆匆过客 提交于 2019-12-05 08:18:52

By default argparse uses the gettext module to translate the messages so you can easily translate them if you want to.

To generate the *.pot files (which you can convert to *.mo files after translation) you can use the pygettext program which is available in the built-in gettext module in python.

Usage:

python pygettext.py argparse.py

This will generate a messages.pot which you can translate, after that just generate the .mo (many ways to do this, just google).

For more info about pygettext see the Python manual about the subject: https://docs.python.org/2/library/gettext.html#internationalizing-your-programs-and-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!