t = gettext.translation('example', "locale", fallback=True)
_=t.ugettext
print(_("this message"))
2....从源代码中抽取需要国际化的文本消息,并转换创建.pot文件, 可以使用的工具为pygettext.py 或者GNU工具 xgettext
这里我使用xgettext, MAC上使用homebrew...安装, 输入命令:
>brew install xgettext
即可自动完成安装, 安装后的默认目录:/usr/local/Cellar/gettext/0.19.2/,
进入/usr/local/...二进制文件,
cd locale/en_US/LC_MESSAGES/
msgfmt -o example.mo example.po可以看到转换后生成的mo是二进制文件,而po,pot都是文本文件...281, in _parse
raise IOError(0, 'Bad magic number', filename)
IOError: [Errno 0] Bad magic number