Skip to main content

A CLI tool that scans through .po files and searches for mistranslated terms based on user-defined glossary mapping

Project description

poglossary

Python PyPI

A CLI tool that scans through translation project (.po files) searching for mistranslated terms based on the user-defined glossary mapping.

This project is specially tailored for Python Documentation Translation Project (zh_TW) but can be applied for all translation projects that adopt Portable Object files (.po).

Install

To install the current release:

pip3 install poglossary

To update it to the latest version, add --upgrade flag to the above commands.

Run poglossary --help and you should see the following output if it's installed sucessfully.

poglossary --help
# Usage: poglossary [OPTIONS] [PATH] [CONFIG_FILE]

#   poglossary: check translated content in .po files based on given translation
#   mapping

# Arguments:
#   [PATH]         the path of the directory storing .po files  [default: .]
#   [CONFIG_FILE]  input mapping file  [default: ./poglossary.yml]

# Options:
#   --excludes PATH       the directories that need to be omitted
#   --install-completion  Install completion for the current shell.
#   --show-completion     Show completion for the current shell, to copy it or
#                         customize the installation.
#   --help                Show this message and exit.

Usage

Config File

A config file in YAML format is required for poglossary, only the following two keys are recognized:

  • glossary (required): A mapping of untrnaslated term to translated term. The value can be a list if it has multiple translation choices.
  • ignore (optional): If skipping the checking for specific regex patterns or rST syntax is wanted, add the key patterns or rst_tags as the example below.
# Sample config file (.yml)
glossary:
  exception: 例外
  function: 函式
  instance: 實例
  type: # can be a list of possible translated terms of "type"
    - 型別
    - 種類

ignore:
  patterns:
    - "type code(s)?" # "type code" or "type codes" will be skipped
  rst_tags:
    - source # :source:`*` will be skipped
    - class
    - c:
        - func # :c:func:`*` will be skipped
        - data

or you can checkout a more detailed configuration in poglossary.example.yml (, which is the config tend to be used in pydoc-zhtw).

Command

poglossary <source_path> <config_file>

poglossary takes in two optional arguments:

  • source_path: It can be the path of the target PO file or a directory that stores PO files. Defaults to ..
  • config_file: The path of the config file. Defaults to ./poglossary.yml.

The sample output is shown below:

image

Todo

  • Functionality
    • More handy parameters/options
  • CI/CD
    • Unit tests
  • Config files
    • Handle missing fields.
    • Commands for creating a basic config file.

Acknowledge

poglossary is primarily inspired by those fantastic translator tools collected in poutils and translate toolkit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poglossary-0.1.4.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

poglossary-0.1.4-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file poglossary-0.1.4.tar.gz.

File metadata

  • Download URL: poglossary-0.1.4.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.0 Linux/5.11.0-1027-azure

File hashes

Hashes for poglossary-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ba2a4f9e9c5a365f2c19bd2ed91ea247d7213299f8aa7065327d9977b401f60f
MD5 cb8f8f5f69e2f13b942a67eb3b40e363
BLAKE2b-256 1c26d5fddcea1761d4536c968505000b5fef9c40c2328a6a08a92b65cf7d6767

See more details on using hashes here.

File details

Details for the file poglossary-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: poglossary-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.0 Linux/5.11.0-1027-azure

File hashes

Hashes for poglossary-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 50f8fba1def2e62852c5a7f9fa66d79e5efd0a058989a70d3455074fd4c35b8e
MD5 f55aae7efcc237b6f4fdf2487294d1f4
BLAKE2b-256 d4f466e16f63a8ae20d2240e908a72b6763ecaf9468b80f6e89d7715ecd14fdb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page