Skip to main content
chki18n

chki18n for Python

license PyPI Python versions

📘 chki18n.cdget.com

Every check, every option and every example. This README is just the quick start.


chki18n checks that your i18n translation files agree with each other. Point it at a folder of JSON, name the language everything is compared against, and it reports what is missing, what was never translated and what quietly broke.

  • Twenty-five checks — missing keys, a language file nobody created, keys defined twice, empty values, untranslated strings, mismatched interpolation placeholders, dropped markup, changed numbers, invisible characters, drifting terminology, missing plural forms, and — pointed at your sources — keys nothing references and keys nothing defines.
  • Every layout — one file per locale, one folder per locale, or one file holding them all.
  • CLI and library share one set of checks and one set of options.
  • A report you can act on — grouped by language, check, file or nothing; rendered for a terminal, for grep, as JSON, as Markdown or as GitHub Actions annotations; saved to a file on request.
  • No dependencies, fully typed, and chki18n.core reaches no file system at all.

Install

pip install chki18n

Requires Python 3.10 or newer.

From the command line

chki18n ./locales --target en
  Path     ./locales
  Target   en
  Locales  en, ko
  Layout   single, 1 group, 10 keys

 ko ──────────────────────────────────────────────────────────────────────── 1 error · 1 warning

  ERROR  NO_KEY (1)
         The key exists in the target language but is missing here.
    attr.folder  en: "Folder"

  WARN   NOT_TRANSLATED_VALUE (1)
         The value is identical to the target language, so the translation may be incomplete.
    desc.no-str  en: "12345"

 Summary ───────────────────────────────────────────────────────────────────────────────────────

  Compared 10 keys across 2 locales in 1 group. (3ms)
  1 error · 1 warning
  Clean: en

  FAIL  1 error must be fixed before this passes.

Exits with 1 when an error level issue was found, so a CI job fails on it. chki18n --help lists every flag. Without installing it, pipx run chki18n ./locales --target en does the same thing.

--group-by decides what a section is (locale, code, group, file or none), --reporter decides the shape (pretty, list, json, markdown or github), and --output keeps a copy:

chki18n ./locales --target en --reporter json > report.json
chki18n ./locales --target en --output translation-report.md

From Python

Four entry points, depending on who owns the translations:

from chki18n import (
    Entry,
    Input,
    Options,
    analyze_translations,
    check_translation_files,
    create_analyzer,
    load_translations,
)

# Check a directory once — the same thing the CLI does.
result = check_translation_files("./locales", Options(target="en"))

result.success  # False
result.issues  # every issue, with its level, key, locale and file

# Check data you already have, with no file system work at all.
analyze_translations(Input(locales={"en": en, "ko": ko}), Options(target="en"))

# Read a directory once, then check it as often as you like.
session = load_translations("./locales", Options(target="en"))
session.set("ko", "desc.hello", "안녕하세요")  # the issues for that key

# Or let your own application own the values and ask only for a verdict.
create_analyzer(Options(target="en")).check_entry(
    Entry(key="desc.hello", values={"en": "Hello {name}", "ko": "안녕하세요"})
)
# [Issue(code='NO_INTERPOLATION_KEY', level='error', locale='ko', ...)]

The last two do no file system work and are also importable as chki18n.core, which reaches no file system at all.

Every option is one keyword-only object, so a flag and its Python counterpart are the same thing. The loose forms a command line writes are accepted here too:

Options(
    target="en",
    ignore_checks=["SUSPICIOUS_LENGTH"],  # or "SUSPICIOUS_LENGTH"
    levels={"EMPTY_VALUE": "error"},  # or "EMPTY_VALUE=error"
    key_case="kebab",
    reporter="markdown",
)

The documentation site covers every check, every option and how to render a result.

Contributing

Anyone can contribute by reporting an issue or opening a pull request. See CONTRIBUTING.md.

License

Released under the MIT License.

Download files

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

Source Distribution

chki18n-1.1.0.tar.gz (80.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chki18n-1.1.0-py3-none-any.whl (77.9 kB view details)

Uploaded Python 3

File details

Details for the file chki18n-1.1.0.tar.gz.

File metadata

  • Download URL: chki18n-1.1.0.tar.gz
  • Upload date:
  • Size: 80.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for chki18n-1.1.0.tar.gz
Algorithm Hash digest
SHA256 aad895bf2aa1ab1b0e423468435f28e14cad40d25565e70456dae6016c06a820
MD5 d2edfcc065a2329b882c6cf6edd236fb
BLAKE2b-256 121b3115e797389c19bfaffb6e5cddf6ede5dd5bbdc95a46d045d4e89f129be9

See more details on using hashes here.

File details

Details for the file chki18n-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: chki18n-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 77.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for chki18n-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85f26e4dfa3109d1a0093db231f8e657a8e28e284328e70f06f367e9b8efce18
MD5 728f9a3dda05304998410094e9f53bc4
BLAKE2b-256 4552e66da84241a6e52386813f5587ad45c0d40e97e8de2edd8e9747f3e60644

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.0

2 files

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