Skip to main content

LocaleLens

LocaleLens: paired language keys

Every key. Every locale. No network.

Offline localization QA for JSON and Flutter ARB resources.

v0.1.1 · Python 3.10+ · zero runtime dependencies · MIT

GitHub stars Offline 11 tests passed locally CI MIT


The missing translation

An English settings screen has a Cancel button. Its Arabic resource has the same key, but the value is empty. A key-count comparison would miss the problem.

Key English (en) العربية (ar)
welcome Hello {name}! أهلاً {name}!
settings.save Save حفظ
settings.cancel Cancel (empty)

These are examples from the included resources: English and Arabic.

From the source directory, compare the files:

python -m localelens fixtures/en.arb fixtures/ar.arb --format markdown

The actual example result:

1 error · 0 warnings

Severity Code JSON pointer Detail
error blank /settings/cancel nonblank source translated to blank string

The command exits with code 1. Fix the translation or review the reported key, then rerun the comparison. A supplied clean Arabic fixture demonstrates a passing report.

What gets checked

Compare a reference locale with a translated locale and get a stable, actionable report. No API keys, no online service, no modification of translation files.

Check Result
Missing keys or array positions Error
Extra keys or array positions Warning
Different JSON value types Error
Nonblank reference translated as blank Error
Named or positional placeholder mismatch Error
Latin-only text in an Arabic locale (--rtl) Warning
Additional replacement characters or suspicious ASCII ??? runs (--check-unicode) Warning

Deep paths are expressed as JSON Pointers, so keys containing / or ~ stay unambiguous. When an entire object is missing, one issue identifies the missing subtree. ARB metadata keys starting with @ are ignored at the root.

Run it locally

Python 3.10+ is the only runtime prerequisite. From the source directory:

python -m localelens fixtures/en.arb fixtures/ar.arb
python -m localelens fixtures/en.arb fixtures/ar_clean.arb --format markdown --rtl

Install locally if you prefer a standalone command (requires setuptools for building):

python -m pip install .
localelens fixtures/en.arb fixtures/ar.arb --format markdown

CLI reference

localelens SOURCE TARGET [--format json|markdown] [--rtl]
           [--skip-placeholders] [--check-unicode] [--fail-on error|warning|never]

json is the default output format. Reports are printed to stdout so they can be redirected to an artifact. Input errors go to stderr. Reports explicitly use UTF-8 output, even if the inherited terminal encoding is not UTF-8. Invalid UTF-8, unpaired Unicode surrogates and nonfinite numbers are rejected. The comparison does not modify either resource.

Exit code Meaning
0 Checks passed (or selected failure threshold not reached)
1 Report contains issues meeting the selected threshold
2 Invalid arguments, JSON, unsupported resource type, or file read error

For stricter CI, pass --fail-on warning. For reporting without fail-on-issue behavior, pass --fail-on never; invalid input still exits 2.

JSON report from the example

{
  "summary": {"errors": 1, "warnings": 0},
  "issues": [
    {"severity": "error", "code": "blank", "path": "/settings/cancel", "detail": "nonblank source translated to blank string"}
  ]
}

Placeholder scope

Checks recognize named placeholders ({name}, {{name}}), common ICU argument starts such as {count, plural, ...}, and basic printf %s, %d, %i, %f with optional positional indexes (%2$s). Named placeholder presence rather than raw occurrence counts is compared so locale-specific plural variants do not trigger spurious failures. Complex ICU quoting, printf width/precision, nested custom syntaxes, plural-category completeness and translation meaning are outside this utility's scope; use --skip-placeholders if the project uses unsupported conventions. --rtl only flags Latin-only strings for human review, not incorrect layout or linguistic quality.

Optional Unicode review

Use --check-unicode to flag newly introduced U+FFFD replacement characters and additional runs of at least three ASCII question marks. These patterns may indicate corruption; they are only warnings and cannot prove which original characters were lost. Ordinary Arabic punctuation ؟ is unaffected. To fail CI on these warnings, add --fail-on warning.

Reliability and tests

python -m unittest discover -s tests -v

The included fixtures are synthetic English and Arabic resources. Inputs must have valid UTF-8 JSON object roots and be at most 10 MiB each. Duplicate keys and nonstandard JSON constants are rejected. Tests exercise the real CLI, structural checks, placeholder handling, ARB metadata, determinism and exit codes. CI is configured for Python 3.10/3.12 on Linux and Windows; the platforms are verified by the workflow when it runs.

License

MIT. See LICENSE and third-party notices.

Metadata

Release files for localelens 0.1.1

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

Source distribution (sdist)

Source distribution for localelens 0.1.1
File Size Uploaded Provenance Actions
localelens-0.1.1.tar.gz 14.4 kB With provenance Details for localelens-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for localelens 0.1.1
File Interpreter ABI Platform Actions
localelens-0.1.1-py3-none-any.whl Python 3 none any Details for localelens-0.1.1-py3-none-any.whl

Total release size: 24.5 kB

Release files / localelens-0.1.1.tar.gz

Download URL localelens-0.1.1.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b5075909f38edea6e4970a566f1145f6ccb07ff3bd30480c7efdb10ac7583916
BLAKE2b-256 checksum
How to use checksums
eea6bc13526d477eca309e3130d91cc7f02d613fef090656ed75a31c23b841df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / localelens-0.1.1-py3-none-any.whl

Download URL localelens-0.1.1-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08075f466051e7100dc3e81963ccb5b5bdc81f98617e43464beb94fc7eee5011
BLAKE2b-256 checksum
How to use checksums
ca3428a7703d802e93a6dfea1f52efa40c195653553142e3cf5845347fcf211b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for localelens 0.1.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for localelens-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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