Metadata-Version: 2.4
Name: i18n-fastapi
Version: 0.1.0
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: Topic :: Software Development :: Internationalization
Classifier: Typing :: Typed
Requires-Dist: fastapi>=0.100.0
Requires-Dist: orjson>=3.9.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pytest>=8.0.0 ; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0 ; extra == 'dev'
Requires-Dist: httpx>=0.27.0 ; extra == 'dev'
Requires-Dist: ruff>=0.4.0 ; extra == 'dev'
Requires-Dist: mypy>=1.10.0 ; extra == 'dev'
Requires-Dist: maturin>=1.5,<2.0 ; extra == 'dev'
Requires-Dist: pre-commit>=3.7.0 ; extra == 'dev'
Requires-Dist: watchfiles>=0.20.0 ; extra == 'reload'
Provides-Extra: dev
Provides-Extra: reload
License-File: LICENSE
Summary: High-performance i18n for FastAPI with Rust-powered translation engine
Keywords: fastapi,i18n,internationalization,rust,translations
Author-email: Johnatan Palacios Londoño <johnatan.palacios@utp.edu.co>
License: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# i18n-fastapi

[![PyPI version](https://img.shields.io/pypi/v/i18n-fastapi.svg)](https://pypi.org/project/i18n-fastapi/)
[![Python versions](https://img.shields.io/pypi/pyversions/i18n-fastapi.svg)](https://pypi.org/project/i18n-fastapi/)
[![License](https://img.shields.io/pypi/l/i18n-fastapi.svg)](https://github.com/johnatanpalacios/i18n-fastapi/blob/main/LICENSE)
[![CI](https://img.shields.io/github/actions/workflow/status/johnatanpalacios/i18n-fastapi/ci.yml?branch=main&label=CI)](https://github.com/johnatanpalacios/i18n-fastapi/actions)

High-performance internationalization for FastAPI, powered by a Rust translation engine with automatic Python fallback.

## Features

- **Rust-powered engine** — blazing-fast translation lookups via PyO3, with pure Python fallback
- **ICU plural support** — zero / one / two / few / many / other
- **Configurable locale detection** — query params, cookies, headers, path prefix, in any priority order
- **Plugin pattern** — one-line setup with `I18n(app)`
- **Multiple locale directories** — shared + per-module translations with filename-based namespacing
- **Duplicate key detection** — catch conflicts at startup, not at runtime
- **Hot reload** — watch translation files during development
- **Built-in endpoint** — `GET /i18n/languages` returns available locales
- **FastAPI dependencies** — inject `Locale` and `TranslateFunc` into route handlers

## Installation

```bash
pip install i18n-fastapi
```

For hot reload during development:

```bash
pip install "i18n-fastapi[reload]"
```

## Quick Start

Create translation files:

```
locales/
├── en/
│   └── messages.json    # {"greeting": "Hello {name}"}
└── es/
    └── messages.json    # {"greeting": "Hola {name}"}
```

Set up your app:

```python
from fastapi import FastAPI
from i18n_fastapi import I18n, t

app = FastAPI()
I18n(app)

@app.get("/greet")
async def greet():
    return {"message": t("messages.greeting", name="World")}
```

Request with `?lang=es` or `Accept-Language: es` and the response adapts automatically.

## Documentation

- **[Usage Guide](docs/USAGE.md)** — configuration, locale detection, pluralization, and more
- **[Contributing](CONTRIBUTING.md)** — how to set up the dev environment, run tests, and submit PRs
- **[Publishing](docs/PUBLISHING.md)** — how to publish releases to PyPI
- **[Changelog](CHANGELOG.md)** — version history
- **[Code of Conduct](CODE_OF_CONDUCT.md)** — community standards

## Author

Johnatan Palacios Londoño — [johnatan.palacios@utp.edu.co](mailto:johnatan.palacios@utp.edu.co)

## License

[MIT](LICENSE)

