Skip to main content

Detect unnatural / broken translations in locale files with ZERO LLM. Placeholders, untranslated strings, wrong script, repeats and more. Optional AI layer for fix suggestions. Works in any Python backend.

Project description

lang-natural (Python)

Detect unnatural / broken translations in your locale files — with zero LLM. Catches dropped placeholders, untranslated strings, wrong script, repeated words, markup drift and length anomalies. Runs fully offline, no API key. An optional AI layer (--fix) suggests natural rewrites only when you ask.

For Python backends (Django, FastAPI, Flask) that keep user-facing strings in JSON.

Install

pip install lang-natural

Configure — lang-natural.config.json

{
  "localesDir": "./locales",
  "sourceLocale": "en",
  "targetLocales": ["ar", "es", "hi"],
  "failOn": "error"
}

Run

lang-natural                 # scan and print the report
lang-natural --json          # machine-readable output
lang-natural --fix           # LLM fix suggestions (needs GEMINI_API_KEY)

Exit code is 1 when blocking issues are found — so it fails CI.

Use in code

from lang_natural import detect

issues = detect("cart.itemCount", "ar",
                "You have {count} items", "لديك عناصر")
for i in issues:
    print(i.severity, i.message)

What the local (no-LLM) detector catches

  • Empty translations
  • Missing / extra placeholders ({count}, {{name}}, %s)
  • Strings identical to the source (untranslated)
  • Wrong script (Latin text in an Arabic/Hindi/… locale)
  • Repeated words
  • HTML/markup that differs from the source
  • Length outliers vs. the locale's typical ratio

Subtle word-order naturalness and rewrite suggestions require the optional LLM layer (--fix).

MIT

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

lang_natural-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

lang_natural-0.1.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file lang_natural-0.1.0.tar.gz.

File metadata

  • Download URL: lang_natural-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for lang_natural-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2400d54e7d05fe7a1c8338c722e517e121a063fc1601f1841ac9f2c8b042a051
MD5 929a637bc4029ed7410a52fe37444009
BLAKE2b-256 e3b6743b4add1d2cec976f7773799db41c5b91247a822971edc1170de88980c9

See more details on using hashes here.

File details

Details for the file lang_natural-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lang_natural-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for lang_natural-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e80ef61e62ae4636f83d1094dbaba9213d83041ea650e7be665e88738fbb6bcb
MD5 d1fa4e10d28a802e6e0d8ff827eec130
BLAKE2b-256 4f8c99d6a7917b0c2a27af76d636793c74c14b73edb3dbf40cb43dba38d1cf5b

See more details on using hashes here.

Supported by

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