Skip to main content

pre-commit-po-hooks

PyPI Python versions License Tests

Hooks for pre-commit useful working with PO files.

Example configuration

- repo: https://github.com/mondeja/pre-commit-po-hooks
  rev: v1.7.3
  hooks:
    - id: obsolete-messages
    - id: untranslated-messages
    - id: fuzzy-messages
    - id: remove-django-translators
    - id: standard-metadata
    - id: max-lines
      args: ["10000"]

Hooks

obsolete-messages

Checks for obsolete messages printing their line numbers if found.

untranslated-messages

Checks for untranslated messages printing their line numbers if found.

Parameters

  • -m/--min: Minimum number of messages that must be translated in each file to pass this check. Can be defined as a percentage of the messages translated appending a character % at the end of the value.

fuzzy-messages

Checks for fuzzy messages printing their line numbers if found.

lreplace-extracted-comments

Replaces a matching string at the beginning of extracted comments.

Parameters

  • -m/--match "STRING": Matching string to be replaced.
  • -r/--replacement "STRING": Replacement for the match at the beginning of the extracted comment. If you want to remove the matching beginning you can pass an empty string "".
  • -d/--dry-run: Don't do the replacements, only writes to stderr the locations of the extracted comments to be replaced.

remove-django-translators

Same as lreplace-extracted-comments passing --match "Translators: " --replacement "". Useful to remove the string prepended by Django extracting messages with xgettext (see more about this problem in django-rosetta#245).

check-metadata

Check that metadata fields matches a set of regular expressions.

Parameters

  • -h/--header HEADER: Header name to match in metadata. This argument can be passed multiple times, but after each -h/--header argument must be a -v/--value that indicates the regular expression for that header.
  • -v/--value REGEX: Can be passed multiple times. Indicates the regular expression that the last header passed in the argument -h/--header must match in the checked PO files.
  • -n/--no-metadata: When this option is passed, the hook instead checks that there is no metadata in the files, so it will exit with code 1 if some metadata is found in a file or 0 if there is no metadata in any files.
  • -r/--remove/--remove-metadata: When this option is passed the metadata will be removed from the files instead of being treated as a lint error.

standard-metadata

Check that the metadata of your PO files fits some standard requirements based on the next regular expressions:

  • Project-Id-Version: \d+\.\d+\.\d
  • Report-Msgid-Bugs-To: .+\s<.+@.+\..+>
  • Last-Translator: .+\s<.+@.+\..+>
  • Language-Team: .+\s<.+@.+\..+>
  • Language: \w\w_?\w?\w?(@\w+)?
  • Content-Type: text/plain; charset=[0-9a-zA-Z\-]+
  • Content-Transfer-Encoding: \d+bits?

If you need to replace some fields with other regular expressions, you can do it passing the -h and -v arguments of the check-metadata hook.

For example, if your version includes the character v at the beginning: -h "Project-Id-Version" -v "v\d+\.\d+\.\d"

no-metadata

It will check if PO files has metadata. If has metadata, it will fail the check returning exit code 1.

Parameters

  • -r/--remove/--remove-metadata: When this option is passed the metadata will be removed from the files instead of being treated as a lint error.

remove-metadata

Remove metadata headers from your PO files. This is an alias for no-metadata hook passing --remove-metadata argument.

max-messages

Define a maximum number of entries for each PO file. Pass an interger in the first argument:

- id: max-messages
  args:
    - "5000"

Parameters

  • Maximum number of messages allowed for each PO file.

max-lines

Define a maximum number of lines for each PO file. Pass an interger in the first argument:

- id: max-lines
  args:
    - "10000"

Parameters

  • Maximum number of lines allowed for each PO file.

min-translated

Define a minimum number of files that must be translated in order to pass. Pass a float or a value ending with % character if you wan to compare against the percentage of translated files:

- id: min-translated
  args:
    - "95%"

Parameters

  • Minimum number or percentage of messages which must be translated in each PO file.

Metadata

Release files for pre-commit-po-hooks 1.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pre-commit-po-hooks 1.7.3
File Size Uploaded Provenance Actions
pre_commit_po_hooks-1.7.3.tar.gz 11.5 kB Without provenance Details for pre_commit_po_hooks-1.7.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pre-commit-po-hooks 1.7.3
File Interpreter ABI Platform Actions
pre_commit_po_hooks-1.7.3-py2.py3-none-any.whl Python 2, Python 3 none any Details for pre_commit_po_hooks-1.7.3-py2.py3-none-any.whl

Total release size: 24.7 kB

Release files / pre_commit_po_hooks-1.7.3.tar.gz

Download URL pre_commit_po_hooks-1.7.3.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
945aa4a00943803bb03c0119724c5f1de74743d34ccb03b7ba9011683dbbdf5a
BLAKE2b-256 checksum
How to use checksums
707c083e9bc59f8ad4157c9ce4f963106612eb987915a616ac4a7dc99c559ee4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / pre_commit_po_hooks-1.7.3-py2.py3-none-any.whl

Download URL pre_commit_po_hooks-1.7.3-py2.py3-none-any.whl
Size 13.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
10bd4a15b8abc68a7dfff6eeeb52d02bd67ed8db2ef104a9ba81d2e233037517
BLAKE2b-256 checksum
How to use checksums
a2eef4af5d2efc11be632eeb84c658db2c7f1c5739906d01333943e059fefe01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Security for pre-commit-po-hooks 1.7.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page