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 simple flashcard app built as a final project for a databases class.

CS2300 Final Project - Flashcard app 'FlashStudy' Tech stack Backend Python (Language) Django (Web framework) SQLite (Database) Frontend HTML/CSS/Java

Christopher Spencer 2 Feb 03, 2022
Runtime fault injection platform by Daniele Rizzieri (2021)

GDBitflip [v1.04] Runtime fault injection platform by Daniele Rizzieri (2021) This platform executes N times a binary and during each execution it inj

Daniele Rizzieri 1 Dec 07, 2021
Tool to audit and fix Python project requirements.

Requirement Auditor Utility to revise and updated python requirement files.

Luis Carlos Berrocal 1 Nov 07, 2021
A basic animation modding workflow for FFXIV

AnimAssist Provides a quick and easy way to mod animations in FFXIV. You will need: Before anything, the VC++2012 32-bit Redist from here. Havok will

liam 37 Dec 16, 2022
This repository is an archive of emails that are sent by the awesome Quincy Larson every week.

Awesome Quincy Larson Email Archive This repository is an archive of emails that are sent by the awesome Quincy Larson every week. If you fi

Sourabh Joshi 912 Jan 05, 2023
Python with the scientific stack, compiled to WebAssembly.

Pyodide may be used in any context where you want to run Python inside a web browser.

9.5k Jan 09, 2023
A "multiclipboards" script for an efficient way to improve the original clipboards which are only able to save one string at a time

A "multiclipboards" script for an efficient way to improve the original clipboards which are only able to save one string at a time. Works on both Windows and Linux.

1 Jan 24, 2022
A test repository to build a python package and publish the package to Artifact Registry using GCB

A test repository to build a python package and publish the package to Artifact Registry using GCB. Then have the package be a dependency in a GCF function.

1 Feb 09, 2022
Code and yara rules to detect and analyze Cobalt Strike

Cobalt Strike Resources This repository contains: analyze.py: a script to analyze a Cobalt Strike beacon (python analyze.py BEACON) extract.py; extrac

Tek 224 Jan 04, 2023
Our Ping Pong Project of numerical analysis, 2nd year IC B2 INSA Toulouse

Ping Pong Project The objective of this project was to determine the moment of impact of the ball with the ground. To do this, we used different model

0 Jan 02, 2022
Python programs, usually short, of considerable difficulty, to perfect particular skills.

Peter Norvig MIT License 2015-2020 pytudes "An étude (a French word meaning study) is an instrumental musical composition, usually short, of considera

Peter Norvig 19.9k Dec 27, 2022
APRS Track Direct is a collection of tools that can be used to run an APRS website

APRS Track Direct APRS Track Direct is a collection of tools that can be used to run an APRS website. You can use data from APRS-IS, CWOP-IS, OGN, HUB

Per Qvarforth 42 Dec 29, 2022
🤖🤖 Jarvis is an virtual assistant which can some tasks easy for you like surfing on web opening an app and much more... 🤖🤖

Jarvis 🤖 🤖 Jarvis is an virtual assistant which can some tasks easy for you like surfing on web opening an app and much more... 🤖 🤖 Developer : su

1 Nov 08, 2021
This project intends to take the user's CEP (brazilian adress code) and return the local in which the CEP is placed.

This project aims to simply return the CEP's (the brazilian resident adress code) User of the application. The project uses a request and passes on to

Daniel Soares Saldanha 4 Nov 17, 2021
MIB2 STD ZR Firmware Upgrade

Upgrade MIB2 STD ZR Firmware (without Navigation) About This repository contains some scripts and documentation how to upgrade the MIB2 firmware to a

Fabian 18 Dec 29, 2022
An alternative app for core Armoury Crate functions.

NoROG DISCLAIMER: Use at your own risk. This is alpha-quality software. It has not been extensively tested, though I personally run it daily on my lap

12 Nov 29, 2022
A modern message based async agent framework

Munggoggo A modern message based async agent framework An asyncio based agent platform written in Python and based on RabbitMQ. Agents are isolated pr

24 Dec 28, 2022
NotesToCommands - a fully customizable notes / command template program, allowing users to instantly execute terminal commands

NotesToCommands is a fully customizable notes / command template program, allowing users to instantly execute terminal commands with dynamic arguments grouped into sections in their notes/files. It w

zxro 5 Jul 02, 2022
FindUncommonShares.py is a Python equivalent of PowerView's Invoke-ShareFinder.ps1 allowing to quickly find uncommon shares in vast Windows Domains.

FindUncommonShares The script FindUncommonShares.py is a Python equivalent of PowerView's Invoke-ShareFinder.ps1 allowing to quickly find uncommon sha

Podalirius 184 Jan 03, 2023
A New, Interactive Approach to Learning Python

This is the repository for The Python Workshop, published by Packt. It contains all the supporting project files necessary to work through the course from start to finish.

Packt Workshops 231 Dec 26, 2022