Skip to main content

A self-healing localization layer for Python applications, automatically creating missing language files and keys.

Project description

Self‑Healing Localization Layer

Automatic, self‑maintaining localization for any Python project

Author: Tuomas Lähteenmäki
License: MIT
Version: 0.1.5


🌍 Overview

Self‑Healing Localization Layer (SHL) is a lightweight, dependency‑free Python library that eliminates missing translations forever.

It provides:

  • Automatic creation of missing language files
  • Automatic creation of missing keys
  • Fallback to a base language (default: English)
  • Unified support for both UI text and optional AI prompt templates

✨ Key Features

✔ Self‑healing UI localization

  • Missing language files are created automatically
  • Missing keys are added on the fly
  • Base language is used as fallback

✔ Self‑healing AI prompt template localization

  • Missing template files are generated automatically
  • Base templates are copied as fallback
  • Missing template keys are added automatically

✔ Unified high‑level engine

The LocalizationEngine ties everything together:

  • ensures languages exist
  • synchronizes all languages with the base language
  • provides clean access to UI text and templates

✔ Zero dependencies

Pure Python. Works everywhere.


📦 Installation

Currently available via TestPyPI (v0.1.5):

pip install --index-url [https://test.pypi.org/simple/](https://test.pypi.org/simple/) self-healing-localization==0.1.5

Self‑Healing Localization Layer (SHL) is a lightweight, dependency‑free Python library that eliminates missing translations forever.

It provides:

  • automatic creation of missing language files
  • automatic creation of missing keys
  • fallback to a base language (default: English)
  • unified support for both UI text and AI prompt templates

This library is designed to be dropped into any project — from small scripts to full applications — and it will maintain localization files automatically as the project grows.

No more manual JSON editing.
No more “missing translation” errors.
No more incomplete language packs.


🚀 Quick Start

1. Basic UI Localization

Initialize the engine and start retrieving text. If the key doesn't exist, it is added to your JSON files automatically.

from shl.engine import LocalizationEngine

# Initialize the engine (e.g., set user language to Finnish)
engine = LocalizationEngine(lang_code="fi", base_lang="en")

# Retrieve UI text. If 'welcome_msg' is missing, it's created with the default value.
title = engine.ui_text("welcome_msg", "Welcome to the App!")

print(title)

2. Retrieve UI text

title = engine.ui_text("app_title", "My Application")

If "app_title" does not exist in locales/lang_en.json, it will be added automatically.

3. Retrieve prompt templates

summary_prompt = engine.template("summary_short", "Summarize the text:")

If prompts/fi.json does not exist, it will be created automatically using prompts/en.json as the base.

4. AI Prompt Templates

Keep your AI prompts localized just like your UI strings.

# Retrieve a localized prompt template
prompt = engine.template("summarize_task", "Please summarize the following text:")

🧩 Project Structure

The library follows a modular design to keep the core logic separate from your application code:

self-healing-localization/
│
├─ shl/
│  └─ engine/                 # Core modular engine
│     ├─ core.py              # Main LocalizationEngine
│     ├─ localizer.py         # UI text logic
│     ├─ template_localizer.py # AI template logic
│     ├─ ai_translation.py    # (Coming in v0.2)
│     └─ __init__.py          # Internal package exports
│
├─ pyproject.toml             # Package configuration
└─ README.md                  # Project documentation

🔧 API Reference (v0.1.x)

Initialize

engine = LocalizationEngine(lang_code="en")

UI text

engine.ui_text(key, default="")

Template text

Template localization is available in v0.1.x but considered experimental and subject to change.

engine.template(key)

Ensure language exists

engine.ensure_language("de")

Sync all languages with base language

engine.sync()
  • SHL is currently focused on UI localization.
  • Prompt template localization is considered an advanced / experimental feature in v0.1.x.

🛠 Roadmap

v0.1.x:

  • Core self-healing logic and modular engine.

v0.1.4

  • Basic automatic translation engine (e.g., English -> Finnish).

v0.3.0

  • AI‑powered translation (Gemini / Groq / OpenAI)
  • CLI tool (selfheal sync, selfheal translate)
  • Automatic detection of missing keys across all languages

v0.4.0

  • Web‑based Localization Studio
  • Visual diffing of translations
  • Export/import language packs

v1.0

  • Full ecosystem integrations (Flask, FastAPI, Django, Flet)
  • Community templates
  • Official PyPI release

🤝 Contributing

Contributions are welcome.
This project aims to become a new standard for open‑source localization — simple, automatic, and self‑maintaining.


📄 License

MIT License — free for personal and commercial use.


⭐ Vision

Localization should never be a burden.

With SHL, any project can become multilingual — automatically, reliably, and without manual maintenance.

No more missing translations.
No more incomplete language packs.
Localization that heals itself.

#localization • #i18n • #l10n • #self-healing • #translation • #multilingual
#json • #python • #developer-tools • #automation • #templates • #cli
#ai-assisted • #language-files • #internationalization • #localization-engine

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

self_healing_localization-0.1.5.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

self_healing_localization-0.1.5-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file self_healing_localization-0.1.5.tar.gz.

File metadata

File hashes

Hashes for self_healing_localization-0.1.5.tar.gz
Algorithm Hash digest
SHA256 368c757e9f15efa74592ad444c79addfb9e21a1df099e5a3e1c148ea4a941726
MD5 694493c4bd61bad12476a595922800fd
BLAKE2b-256 51d3af8fd9079a4a47077e7d0d9225b1383e2175399ffbcc10a7073b57276b60

See more details on using hashes here.

File details

Details for the file self_healing_localization-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for self_healing_localization-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 839cb5e3ab06bf95982eb3f9032b276349030d28256b6802a5b269c1eb98de01
MD5 e27858c6f84e465cf40702ee4c5fcb11
BLAKE2b-256 fd648066e440c44b28b17d8eef9867a9575a1c8bbf80f4f33a71f46931a96a5e

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