Python 标准库 argparse 的非官方翻译项目。
想要贡献?请阅读 贡献指北。
将仓库中的翻译目录放到你的程序下,然后在你的程序中添加下面这些代码:
import argparse
import gettext
import locale
_lang = locale.getdefaultlocale()[0] or "zh-CN" # https://github.com/python/cpython/issues/130796 pylint: disable=deprecated-method / W4902
# 这里设置 zh-CN 为默认语言
t = gettext.translation(
"argparse", "locale", [_lang]
) # 修改 "locale" 为你存放翻译文件的位置
argparse._ = t.gettext # pyright: ignore[reportAttributeAccessIssue]
argparse.ngettext = t.ngettext # pyright: ignore[reportAttributeAccessIssue]本项目采用 CC0 1.0 Universal 许可协议。