Msgcheck
Msgcheck performs various checks on gettext files (with extension .po):
- compilation (with command
msgfmt -c) - for each translation:
- number of lines in translated strings
- whitespace at beginning/end of strings
- trailing whitespace at end of lines inside strings
- punctuation at end of strings
- spelling (messages and translations).
The script requires:
- Python ≥ 3.10
- gettext (for the command
msgfmt, used to compile PO files) - the python module
pyenchantfor spell checking (option-s).
Install
Install a released version from the Python package index with pip:
$ pip install msgcheck
Or you can run via source distribution:
$ uv run msgcheck
Usage
Syntax:
$ msgcheck [options] files [files...]
Options:
-h,--help: display help message and exit-c,--no-compile: do not check compilation of file (withmsgfmt -c)-f,--fuzzy: check fuzzy strings-F,--error-on-fuzzy: raise an error if fuzzy strings are found-n,--check-noqa: check "noqa"-commented lines (they are skipped by default)-l,--no-lines: do not check number of lines-p,--no-punct: do not check punctuation at end of strings-s id|str,--spelling id|str: check spelling (id= source messages,str= translations)-d <dicts>,--dicts <dicts>: comma-separated list of extra dictionaries to use (in addition to file language)-P <file>,--pwl <file>: file(s) with personal list of words used when checking spelling (this option can be given multiple times)-m,--only-misspelled: display only misspelled words (alias of--output-format=misspelled)-w,--no-whitespace: do not check whitespace at beginning/end of strings-W,--no-whitespace-eol: do not check whitespace at end of lines inside strings-e,--extract: display all translations and exit (alias of--output-format=extract)-i,--ignore-errors: display but ignore errors (always return 0)-o,--output-format: output format:full: complete outputoneline: one line outputextract: display all translations (all checks except compilation are disabled in this mode)misspelled: display only misspelled words
-q,--quiet: quiet mode: only display number of errors-v,--version: display version and exit
The environment variable MSGCHECK_OPTIONS can be set with some default options.
The script returns exit code 0 if all files checked are OK (0 errors or option
--extract given) or it returns N: number of files with errors (1 ≤ N ≤ 255).
pre-commit
To use msgcheck with pre-commit, add the following to your .pre-commit-config.yaml:
- repo: https://github.com/flashcode/msgcheck
rev: v4.2.0 # Use the latest tag or a specific commit hash
hooks:
- id: msgcheck
args: [] # add optional arguments like '--fuzzy', see above
Example
$ msgcheck fr.po
======================================================================
/path/to/fr.po:242: [punct] end punctuation: ":" in translation, ":" not in string:
---
error
---
erreur:
======================================================================
/path/to/fr.po:262: [lines] number of lines: 1 in string, 2 in translation:
---
Message filters:
---
Filtres de
messages:
======================================================================
/path/to/fr.po:336: [whitespace] spaces at beginning: 0 in string, 1 in translation:
---
current value
---
valeur courante
======================================================================
/path/to/fr.po: 3 errors (almost good!)
Copyright
Copyright © 2009-2025 Sébastien Helleu
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Metadata
Release files for msgcheck 4.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| msgcheck-4.2.0.tar.gz | 10.8 kB | Without provenance | Details for msgcheck-4.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| msgcheck-4.2.0-py3-none-any.whl | Python 3 | none | any | Details for msgcheck-4.2.0-py3-none-any.whl |
Total release size: 25.0 kB
Release files / msgcheck-4.2.0.tar.gz
| Download URL | msgcheck-4.2.0.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e2c756309248b69a9588ba1bd746b4286eef25cc039732df05224286447a722
|
|
BLAKE2b-256 checksum How to use checksums |
43e87b4c42fad4d67710fcea1363c552e91a6a684719c204657d2a68f259c49e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":null,"id":"forky","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / msgcheck-4.2.0-py3-none-any.whl
| Download URL | msgcheck-4.2.0-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
abdce77eced4df2b8663ce70827587ea69cac84c0bdc729a3d698a7b5c14437c
|
|
BLAKE2b-256 checksum How to use checksums |
3ab74ad01ba3d9efc0b68b6e374f93cc5591782f34a2d637d9a0e48043c01def
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":null,"id":"forky","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for msgcheck 4.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.