Your missing PO formatter and linter

Overview

pofmt

Tests pypi version pre-commit Code style: black

Your missing PO formatter and linter

Features

  • Wrap msgid and msgstr with a constant max width.
  • Can act as a pre-commit hook.
  • Display lint errors in a human readable format.
  • Insert white-spaces between Chinese characters and latin letters with pangu
  • The widths of CJK characters are multiplied by a factor for visual balance.

Requirements

pofmt requires Python >=3.6

Installation

It is recommended to install with pipx, if pipx haven't been installed yet, refer to the pipx's docs

$ pipx install pofmt

Alternatively, install with pip to the user site:

$ python -m pip install --user pofmt

If you are formatting PO files with Chinese, it is recommended to install pofmt[zh]. This includes a handy function to add spaces between CJK characters and latin letters.

As a pre-commit hook

See pre-commit for instructions.

A sample .pre-commit-config.yaml:

- repo: https://github.com/frostming/pofmt
  rev: '0.1.0'
  hooks:
    - id: pofmt
      additional_dependencies: ['pangu']  # for handling Chinese documents

Usage

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

Sample output

`_" -msgstr "`Jinja文档`_" +msgstr "`Jinja 文档 `_" #: ../../index.rst:23 msgid "`Werkzeug documentation `_" -msgstr "`Werkzeug文档`_" +msgstr "`Werkzeug 文档 `_" #: ../../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)。" ">
--- 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 `_"
-msgstr "`Jinja文档`_"
+msgstr "`Jinja 文档 `_"

 #: ../../index.rst:23
 msgid "`Werkzeug documentation `_"
-msgstr "`Werkzeug文档`_"
+msgstr "`Werkzeug 文档 `_"

 #: ../../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)。"
Owner
Frost Ming
Love 🐍 Python, 📷 Photography and beautiful things
Frost Ming
A comparison of mesh generators.

This repository creates meshes of the same domains with multiple mesh generators and compares the results.

Nico Schlömer 29 Dec 12, 2022
Blender addon that enables exporting of xmodels from blender. Great for custom asset creation for cod games

Birdman's XModel Tools For Blender Greetings everyone in the custom cod community. This blender addon should finally enable exporting of custom assets

wast 2 Jul 02, 2022
Project for viewing the cheapest flight deals from Netherlands to other countries.

Flight_Deals_AMS Project for viewing the cheapest flight deals from Netherlands to other countries.

2 Dec 17, 2022
Vaksina - Vaksina COVID QR Validation Checker With Python

Vaksina COVID QR Validation Checker Vaksina is a general purpose library intende

Michael Casadevall 33 Aug 20, 2022
Keep your company's passwords behind the firewall

TeamVault TeamVault is an open-source web-based shared password manager for behind-the-firewall installation. It requires Python 3.3+ and Postgres (wi

//SEIBERT/MEDIA GmbH 38 Feb 20, 2022
Synchrosqueezing, wavelet transforms, and time-frequency analysis in Python

Synchrosqueezing is a powerful reassignment method that focuses time-frequency representations, and allows extraction of instantaneous amplitudes and frequencies

John Muradeli 382 Jan 06, 2023
Projeto-menu - This project is designed to learn more about control mechanisms in Python programming

Projeto-menu - This project is designed to learn more about control mechanisms in Python programming

Henrik Ricarte 2 Mar 01, 2022
👀 nothing to see here

Woofy Woofy is blue dog companion token of YFI (Wifey) It utilizes a special Woof bonding curve which allows two-way conversion between the tokens. Th

Yearn Finance 36 Mar 14, 2022
Ellipitical Curve Table Generator

Ellipitical-Curve-Table-Generator This script generates a table of elliptical po

Nishaant Goswamy 1 Jan 02, 2022
A Python library for inspecting JVM class files (.class)

lawu Lawu is a human-friendly library for assembling, disassembling, and exploring JVM class files. It's highly suitable for automation tasks. Documen

Tyler Kennedy 45 Oct 23, 2022
Lookup for interesting stuff in SMB shares

SMBSR - what is that? Well, SMBSR is a python script which given a CIDR/IP/IP_file/HOSTNAME(s) enumerates all the SMB services listening (445) among t

Vincenzo 112 Dec 15, 2022
Telegram bot to search quotes from brainyquote.com

Brainy Quote Bot @BrainQuoteBot A star ⭐ from you means a lot to us! Telegram bot to search quotes from brainyquote.com Usage Deploy to Heroku Tap on

21 Nov 24, 2022
An account generator for guilded.gg that I made a while back and decided to bring back up

An account generator for guilded.gg that I made a while back and decided to bring back up

8 Nov 17, 2022
Meaningful and minimalist release notes for developers

Managing manual release notes is hard. Therefore, everyone tends to generate release notes from commit messages. But, you won't get a meaningful release note at the end.

codezri 31 Dec 30, 2022
KeyLogger cliente-servidor em Python para estudos

KeyLogger Esse projeto é apenas para estudos, não nos responsabilisamos por qualquer uso indevido ou prejudiciais do mesmo. Sobre O objetivo do projet

1 Dec 17, 2021
Use this function to get list of routes for particular journey

route-planner Functions api_processing Use this function to get list of routes for particular journey. Function has three parameters: Origin Destinati

2 Nov 28, 2021
A simple but flexible plugin system for Python.

PluginBase PluginBase is a module for Python that enables the development of flexible plugin systems in Python. Step 1: from pluginbase import PluginB

Armin Ronacher 1k Dec 16, 2022
An educational platform for students

Watch N Learn About Watch N Learn is an educational platform for students. Watch N Learn incentivizes students to learn with fun activities and reward

Brian Law 3 May 04, 2022
Registro Online (100% Python-Mysql)

Registro elettronico scritto in python, utilizzando database Mysql e Collegando Registro elettronico scritto in PHP

Sergiy Grimoldi 1 Dec 20, 2021
Script to quickly get the metrics from Github repos to analyze.

commit-prefix-analysis Script to quickly get the metrics from Github repos to analyze. Setup Install the Github CLI. You'll know its working when runn

David Carpenter 1 Dec 17, 2022