Python i18n 国际化

发布时间: 更新时间: 总字数:92 阅读时间:1m 作者:IP:上海 网址

Python 国际化 i18n

gettext 介绍

gettext 是一套 GNU 下的国际化工具。主要有工具:

  • xgettext: 从源码中抽取字符串,生成 po 文件(portable object)
  • msgfmt: 将 po 文件编译成 mo 文件(machine object)
  • gettext: 进行翻译

po 文件编译成 mo 文件

text
msgfmt locale/zh_Hans_CN/LC_MESSAGES/messages.po -o locale/zh_Hans_CN/LC_MESSAGES/messages.mo