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ável1.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,
mypyorpyrightdetects it immediately. - Deferred references (
TextandMessage): domain logic can refer to a translation without knowing which language will be resolved at runtime. - HTTP-independent negotiation: parses standard RFC
Accept-Languageheaders with quality weights (q=), wildcard matching (*), prefix fallbacks (pt-BR➔pt), with no coupling to FastAPI, Django, Flask, or any web framework. - PEP 561 compatible: includes
py.typedout 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c04a88aff76d2c317365bfe722357e6d179fc29b0c32e5a01961d2ecc14dd23
|
|
| MD5 |
c00b69fdbdfa767de1642a704e905bb7
|
|
| BLAKE2b-256 |
ab224d4ccce6495dea1e5f4748c7dc0bc94f12a36ddeff0865bdfc8a277fa3ac
|
Provenance
The following attestation bundles were made for wads_dev_i18n-0.0.1a1.tar.gz:
Publisher:
publish.yml on wads-dev/i18n-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wads_dev_i18n-0.0.1a1.tar.gz -
Subject digest:
0c04a88aff76d2c317365bfe722357e6d179fc29b0c32e5a01961d2ecc14dd23 - Sigstore transparency entry: 2816441635
- Sigstore integration time:
-
Permalink:
wads-dev/i18n-python@e2cff6221262b9ef094e960d3aec8325975a47fa -
Branch / Tag:
refs/tags/v0.0.1-alpha.1 - Owner: https://github.com/wads-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e2cff6221262b9ef094e960d3aec8325975a47fa -
Trigger Event:
release
-
Statement type:
File details
Details for the file wads_dev_i18n-0.0.1a1-py3-none-any.whl.
File metadata
- Download URL: wads_dev_i18n-0.0.1a1-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f30f74e25317b34a477c65741eac76cd5b6d64f4497fb8bcdf32f9beba29881
|
|
| MD5 |
b2b1453b3f107ab75055920daf9f87ff
|
|
| BLAKE2b-256 |
050579ca7c377802076ec5f66b8edb880c0257796367de4fabe7fe15d3c6846b
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wads_dev_i18n-0.0.1a1-py3-none-any.whl -
Subject digest:
5f30f74e25317b34a477c65741eac76cd5b6d64f4497fb8bcdf32f9beba29881 - Sigstore transparency entry: 2816441662
- Sigstore integration time:
-
Permalink:
wads-dev/i18n-python@e2cff6221262b9ef094e960d3aec8325975a47fa -
Branch / Tag:
refs/tags/v0.0.1-alpha.1 - Owner: https://github.com/wads-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e2cff6221262b9ef094e960d3aec8325975a47fa -
Trigger Event:
release
-
Statement type: