您缺少的PO格式化和检查器
项目描述
pofmt
您缺少的PO格式化和检查器
特性
- 将msgid和msgstr包裹在最大宽度常量中。
- 可以作为pre-commit钩子。
- 以人类可读的格式显示lint错误。
- 使用pangu在汉字和拉丁字母之间插入空格。
- CJK字符的宽度乘以一个因子以实现视觉平衡。
要求
pofmt需要Python >=3.6
安装
建议使用pipx
进行安装,如果尚未安装pipx
,请参阅pipx的文档
$ pipx install pofmt
或者,使用pip
到用户站点安装
$ python -m pip install --user pofmt
如果您正在格式化包含中文的PO文件,建议安装pofmt[zh]
。这包括一个方便的功能,可以在CJK字符和拉丁字母之间添加空格。
作为pre-commit钩子
有关说明,请参阅pre-commit
示例.pre-commit-config.yaml
- repo: https://github.com/frostming/pofmt
rev: '0.4.0'
hooks:
- id: pofmt
additional_dependencies: ['pangu'] # for handling Chinese documents
用法
USAGE: pofmt [-h] [--line-length LINE_LENGTH] [-c] [--cjk-width CJK_WIDTH] [filename ...]
Format PO files for consistency
positional arguments:
filename Filenames to format, default to all po files under the current directory(recursively)
optional arguments:
-h, --help show this help message and exit
--line-length LINE_LENGTH
The max length of msgid and msgstr
-c, --check Check only, don't modify files
--cjk-width CJK_WIDTH
The width factor of a CJK character, default: 1.8
--no-msgid Don't format msgid
示例输出
--- Original
+++ Current
@@ -21,49 +21,48 @@
msgid "Welcome to Flask"
msgstr "欢迎来到 Flask 的世界"
-msgid "Flask: web development, one "drop" at a time"
+msgid "Flask: web development, one \"drop\" at a time"
msgstr "Flask: Web 开发,一次一滴"
#: ../../index.rst:11
msgid ""
-"Welcome to Flask's documentation. Get started with :doc:`installation` "
-"and then get an overview with the :doc:`quickstart`. There is also a more"
-" detailed :doc:`tutorial/index` that shows how to create a small but "
+"Welcome to Flask's documentation. Get started with :doc:`installation` and"
+" then get an overview with the :doc:`quickstart`. There is also a more "
+"detailed :doc:`tutorial/index` that shows how to create a small but "
"complete application with Flask. Common patterns are described in the "
":doc:`patterns/index` section. The rest of the docs describe each "
"component of Flask in detail, with a full reference in the :doc:`api` "
"section."
msgstr ""
-"欢迎来到Flask的文档。你可以从 :doc:`installation` 入手,然后阅读:doc:`quickstart`来了解基本概念。还有一个包含更多细节的:doc:`tutorial/index`"
-"介绍如何用Flask创建一个很小但是完整的程序。一般的开发模式可以在:doc:`patterns/index`章节找到。剩下的文档详细的介绍了Flask的每一个组成部件,"
-"其中:doc:`api`章节包括完整的API参考信息。"
+"欢迎来到 Flask 的文档。你可以从 :doc:`installation` 入手,然后阅读:doc:`quickstart` "
+"来了解基本概念。还有一个包含更多细节的:doc:`tutorial/index` 介绍如何用 Flask "
+"创建一个很小但是完整的程序。一般的开发模式可以在:doc:`patterns/index` 章节找到。剩下的文档详细的介绍了 Flask "
+"的每一个组成部件,其中:doc:`api` 章节包括完整的 API 参考信息。"
#: ../../index.rst:19
-msgid "Flask depends on the `Jinja`_ template engine and the `Werkzeug`_ WSGI toolkit. The documentation for these libraries can be found at:"
-msgstr ""
-"Flask 依赖 `Jinja`_ 模板引擎和 `Werkzeug`_ WSGI 工具集。这些库的文档如下:"
+msgid ""
+"Flask depends on the `Jinja`_ template engine and the `Werkzeug`_ WSGI "
+"toolkit. The documentation for these libraries can be found at:"
+msgstr "Flask 依赖 `Jinja`_ 模板引擎和 `Werkzeug`_ WSGI 工具集。这些库的文档如下:"
#: ../../index.rst:22
msgid "`Jinja documentation <https://jinja.flask.org.cn/>`_"
-msgstr "`Jinja文档<https://jinja.flask.org.cn/>`_"
+msgstr "`Jinja 文档 <https://jinja.flask.org.cn/>`_"
#: ../../index.rst:23
msgid "`Werkzeug documentation <https://werkzeug.palletsprojects.com/>`_"
-msgstr "`Werkzeug文档<https://werkzeug.palletsprojects.com/>`_"
+msgstr "`Werkzeug 文档 <https://werkzeug.palletsprojects.com/>`_"
#: ../../index.rst:30
msgid "User's Guide"
-msgstr ""
-"用户指南"
+msgstr "用户指南"
#: ../../index.rst:32
msgid ""
"This part of the documentation, which is mostly prose, begins with some "
"background information about Flask, then focuses on step-by-step "
"instructions for web development with Flask."
-msgstr ""
-"这部分的文档大部分是独立章节,以一些关于 Flask 的背景信息开始,然后重点介绍如何"
-"使用 Flask 一步步进行 Web 开发。"
+msgstr "这部分的文档大部分是独立章节,以一些关于 Flask 的背景信息开始,然后重点介绍如何使用 Flask 一步步进行 Web 开发。"
#: ../../index.rst:66
msgid "API Reference"
@@ -73,13 +72,13 @@
msgid ""
"If you are looking for information on a specific function, class or "
"method, this part of the documentation is for you."
-msgstr ""
-"如果你想找关于某个特定函数、类或方法的信息,那么这部分文档就是为你准备的。"
+msgstr "如果你想找关于某个特定函数、类或方法的信息,那么这部分文档就是为你准备的。"
#: ../../index.rst:78
msgid "Additional Notes"
msgstr "附加笔记"
#: ../../index.rst:80
-msgid "Design notes, legal information and changelog are here for the interested."
+msgid ""
+"Design notes, legal information and changelog are here for the interested."
msgstr "如果你感兴趣的话,这里有一些设计笔记、法律信息和变更日志(changelog)。"
项目详情
下载文件
下载适合您平台文件的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
pofmt-0.4.0.tar.gz (10.7 kB 查看哈希值)
构建分发版
pofmt-0.4.0-py3-none-any.whl (8.2 kB 查看哈希值)
关闭
pofmt-0.4.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7a3fb2baaf1225f158f452c63422a646b3bbce9a65fd9ee40deb7667415ca7f2 |
|
MD5 | 19f9b415d3bc22c301475cbbf0a8064b |
|
BLAKE2b-256 | 25e3ebc269949a29cfcf6539eeb9331b9661cf21bdd195408333334a4cb25a2c |
关闭
pofmt-0.4.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7e274d8509e466c322a8e0e6a7825bacbd2e9f92e1a0c95fecba65900468f2cf |
|
MD5 | bc81cd3a88f954cc5ee3f023a636cd0e |
|
BLAKE2b-256 | 7c00fde7a22b90bca9e221431922e59b12621ef02d2089111e1413b72ef31d2d |