Installation
_() and LocaleMiddleware work out of the box with nothing beyond the standard library. Only TranslatableMixin — for translatable SQLAlchemy/SQLModel fields — needs an optional extra.
Requirements
TranslatableMixinLocaleMiddlewareInstall
If you don't have uv installed yet:
curl -LsSf https://astral.sh/uv/install.sh | sh
uv add fastkit-i18n
pip install fastkit-i18n
poetry add fastkit-i18n
This installs _(), TranslationManager, and LocaleMiddleware — ready to use, no additional steps needed.
Optional Dependencies
TranslatableMixin — translatable fields on SQLAlchemy/SQLModel models — needs SQLAlchemy. Everything else works without it:
uv add "fastkit-i18n[sqlalchemy]"
pip install "fastkit-i18n[sqlalchemy]"
sqlalchemy>=2.0 — needed for TranslatableMixin. Works with plain SQLAlchemy declarative models and SQLModel table models alike.What needs the extra?
| Feature | Extra needed? | Installs |
|---|---|---|
_() / TranslationManager |
✓ Included — pure Python, no dependencies | |
LocaleMiddleware |
✓ Included — pure ASGI, no dependencies | |
TranslatableMixin |
[sqlalchemy] |
sqlalchemy>=2.0 |
Importing fastkit_i18n — or using _()/LocaleMiddleware — never requires SQLAlchemy. It's only imported the moment you actually access TranslatableMixin, and you'll get a clear error telling you to install the extra if it's missing.
Verify Installation
Confirm fastkit-i18n is installed correctly:
python -c "from fastkit_i18n import _; print(_('hello'))"
# hello
Or check the installed version:
pip show fastkit-i18n
If you installed the [sqlalchemy] extra, verify TranslatableMixin loads:
python -c "from fastkit_i18n import TranslatableMixin; print('TranslatableMixin OK')"
What do you need?
Not sure where to start? Here's a quick guide based on what you're building:
Use _() on its own — no framework, no database, no extras. Works in scripts, CLIs, or any Python project.
pip install fastkit-i18n # _() works out of the box
Add LocaleMiddleware to any FastAPI/Starlette/Litestar app. Still no extra install needed.
pip install fastkit-i18n # LocaleMiddleware works out of the box
Use TranslatableMixin on your SQLAlchemy or SQLModel models — requires the [sqlalchemy] extra.
pip install "fastkit-i18n[sqlalchemy]"
All three pieces share the same locale context, so you can start with just _() and add LocaleMiddleware or TranslatableMixin later — nothing to rewire.