Skip to main content

Test your translation files.

Project description

version ci coverage license

PyTest Translations

A py.test plugin to check gettext po & mo files.

Test check for:

  • Spelling (using enchant & aspell)

  • Consistency of mo files

  • Obsolete translations

  • Fuzzy translations

Installation

Install the PyPi package.

pip install pytest-translations

The spell checking requires enchant and aspell including the correct dictionary.

On Linux simply install:

sudo apt-get install python3-enchant python-enchant aspell-{en|de|CHOSE YOUR LANGUAGE CODES}

To set up travis-ci simply add the apt packages to your travis-ci config YAML:

addons:
  apt:
    packages:
    - python-enchant
    - python3-enchant
    - aspell-en
    - aspell-de

On Mac you can use brew to install:

brew install aspell --with-lang-{en|de|CHOSE YOUR LANGUAGE CODES}
brew install enchant

Usage

To execute the translation tests simply run

py.test --translations

Every file ending in .mo and .po will be discovered and tested, starting from the command line arguments.

You also can execute only the translation-tests by using:

py.test -m translations --translations

Private Word Lists

You will almost certainly use words that are not included in the default dictionaries. That is why you can add your own word list that you want to add to the dictionary.

You may do so by adding a plain text file where each line is a word. Words beginning with a capital letter are case sensitive where lower case words are insensitive.

There can be one file for each language contained in a single folder. The files should be named like the proper language code.

For example:

.
└── .spelling
    ├── de
    ├── en_GB
    └── en_US

What’s left to do is to set an environment variable to point to right directory.

For example:

export PYTEST_TRANSLATIONS_PRIVATE_WORD_LIST=path/to/my/.spelling

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

pytest-translations-3.1.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

pytest_translations-3.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file pytest-translations-3.1.0.tar.gz.

File metadata

  • Download URL: pytest-translations-3.1.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for pytest-translations-3.1.0.tar.gz
Algorithm Hash digest
SHA256 0f00cf85ed3c73a589ac58053c81713c31d3194db69d3f9c3e83b2f23e7d7693
MD5 e0defe029d39f0256ddc2f5f37d9f884
BLAKE2b-256 180501408e75a023f594d717be6268697cba41466be077bee70c1e59ffab3e69

See more details on using hashes here.

Provenance

File details

Details for the file pytest_translations-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_translations-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for pytest_translations-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a0c8edb8714cca7a6f4ea6b2717bf826487fce28ad19953f62d15fa5e71c1ccc
MD5 e287c9accd1de4d2d6f22d602cd0770a
BLAKE2b-256 37be4db2d4ae675c1c35bbef9bac7def41c641ac971933fa7a02313527e11df1

See more details on using hashes here.

Provenance

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