Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

@wads.dev/i18n-py

Framework-independent Python foundations for strongly typed internationalization.

i18n-py gives Python projects typed translation contracts, deferred string and message references, RFC-compliant Accept-Language negotiation and request-scoped resolvers. It has zero runtime dependencies and no framework lock-in.

⚠️ Status: 0.0.1-alpha. Esta versão é um pré-lançamento alfa experimental (super-alpha). Contratos públicos, nomes de classes e métodos ainda sofrerão alterações antes da versão estável 1.0.0.


Wads.dev i18n ecosystem

Package Environment Responsibility
@wads.dev/i18n-ts TypeScript / JS Core typed contracts, language loading, project configuration and portable JSON bundles.
@wads.dev/i18n-py Python 3.11+ Typed contracts, deferred references, Accept-Language negotiation and resolvers.
@wads.dev/i18n-react React Provider, hooks and rich translation rendering built on i18n-ts.
@wads.dev/i18n-html DOM / Static HTML bindings and static usage discovery built on i18n-ts.
@wads.dev/i18n-editor Tooling Local web editor for inspecting and editing translation bundles.

Why it exists

Translation files are application code: their structure changes, keys move, languages grow, and mistakes should fail during type checking or static analysis rather than reach users in production.

  • Zero dependencies: pure Python (3.11+), no external libraries required.
  • Typed structural contracts: define an immutable dataclass or protocol per module. If a language misses a key or changes an argument signature, mypy or pyright detects it immediately.
  • Deferred references (Text and Message): domain logic can refer to a translation without knowing which language will be resolved at runtime.
  • HTTP-independent negotiation: parses standard RFC Accept-Language headers with quality weights (q=), wildcard matching (*), prefix fallbacks (pt-BRpt), with no coupling to FastAPI, Django, Flask, or any web framework.
  • PEP 561 compatible: includes py.typed out of the box.

Installation

Via PyPI (após publicação)

pip install wads-dev-i18n
# ou com uv:
uv add wads-dev-i18n

Via Git Tag (Alpha)

pip install git+https://github.com/wads-dev/i18n-python.git@v0.0.1-alpha

Quickstart

1. Definir o contrato do módulo (base.py)

from dataclasses import dataclass
from collections.abc import Callable

@dataclass(frozen=True, slots=True)
class AppTranslation:
    welcome: str
    greet_user: Callable[[str], str]

2. Implementar os idiomas

# en.py
en = AppTranslation(
    welcome="Welcome",
    greet_user=lambda name: f"Hello, {name}!",
)

# pt.py
pt = AppTranslation(
    welcome="Bem-vindo",
    greet_user=lambda name: f"Olá, {name}!",
)

3. Criar referências tipadas e catálogo

from wads_dev.i18n import AvailableLangs, Language, Text, Message

WELCOME_TEXT = Text[AppTranslation](lambda lang: lang.welcome)
GREET_MESSAGE = Message[AppTranslation, [str]](lambda lang: lang.greet_user)

CATALOG = AvailableLangs(
    languages={
        "en": Language(locale="en-US", translations=en),
        "pt": Language(locale="pt-BR", translations=pt),
    },
    default="en",
)

4. Resolver a requisição

# Negocia o Accept-Language e vincula ao idioma adequado
resolver = CATALOG.resolve("pt-BR,pt;q=0.9,en;q=0.8")

print(resolver.text(WELCOME_TEXT))       # "Bem-vindo"
print(resolver.message(GREET_MESSAGE, "Victor")) # "Olá, Victor!"

License

MIT © Wads.dev

Download files

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

Source Distribution

wads_dev_i18n-0.0.1a1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

wads_dev_i18n-0.0.1a1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file wads_dev_i18n-0.0.1a1.tar.gz.

File metadata

  • Download URL: wads_dev_i18n-0.0.1a1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for wads_dev_i18n-0.0.1a1.tar.gz
Algorithm Hash digest
SHA256 0c04a88aff76d2c317365bfe722357e6d179fc29b0c32e5a01961d2ecc14dd23
MD5 c00b69fdbdfa767de1642a704e905bb7
BLAKE2b-256 ab224d4ccce6495dea1e5f4748c7dc0bc94f12a36ddeff0865bdfc8a277fa3ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for wads_dev_i18n-0.0.1a1.tar.gz:

Publisher: publish.yml on wads-dev/i18n-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wads_dev_i18n-0.0.1a1-py3-none-any.whl.

File metadata

File hashes

Hashes for wads_dev_i18n-0.0.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f30f74e25317b34a477c65741eac76cd5b6d64f4497fb8bcdf32f9beba29881
MD5 b2b1453b3f107ab75055920daf9f87ff
BLAKE2b-256 050579ca7c377802076ec5f66b8edb880c0257796367de4fabe7fe15d3c6846b

See more details on using hashes here.

Provenance

The following attestation bundles were made for wads_dev_i18n-0.0.1a1-py3-none-any.whl:

Publisher: publish.yml on wads-dev/i18n-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.1a1 This release

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