explaingit

fastkit-org/fastkit-i18n

Analysis updated 2026-05-18

3PythonAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A Laravel-style i18n library for FastAPI that adds translation lookups, automatic locale detection, and translatable database model fields.

Mindmap

mindmap
  root((repo))
    What it does
      Translation lookups
      Locale detection
      Translatable DB fields
    Tech stack
      FastAPI
      SQLAlchemy and SQLModel
      Python 3.10 plus
    Use cases
      Multi language JSON files
      Auto locale middleware
      Translated model fields
    Audience
      FastAPI developers
      Python backend teams
    Related
      fastkit-core
      Validation error translation

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add multi-language JSON translation files to a FastAPI app without writing custom locale-handling code.

USE CASE 2

Automatically detect a user's preferred language from headers, query parameters, or cookies.

USE CASE 3

Store and read translated versions of a database field like a title directly on a SQLAlchemy or SQLModel model.

USE CASE 4

Feed translated messages into Pydantic validation errors via the companion fastkit-core package.

What is it built with?

PythonFastAPISQLAlchemySQLModelPydantic

How does it compare?

fastkit-org/fastkit-i18n0marildo/imago100/geotwitter
Stars333
LanguagePythonPythonPython
Last pushed2015-09-10
MaintenanceDormant
Setup difficultyeasyeasymoderate
Complexity2/52/53/5
Audiencedevelopergeneralgeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

The database-translation feature requires installing the optional sqlalchemy extra.

MIT license: use, modify, and share freely, including commercially, as long as you keep the copyright notice.

In plain English

fastkit-i18n adds translation and multi-language support to FastAPI, a popular Python web framework that has no built-in way to handle different languages. Normally, developers writing FastAPI apps have to manually detect a user's language, look up translated text, and handle fallback text by hand in every part of their code. This package packages all of that into one small library, inspired by how the PHP framework Laravel handles translations. At its core is a simple function that looks up translated text by a dotted key name, like "messages.welcome", pulling from JSON files organized by language code, with support for inserting variable values like a person's name directly into the translated sentence. A middleware component automatically figures out which language to use for each incoming web request, checking the browser's language header, a URL parameter, a cookie, and finally a default setting, in that order, so route handlers rarely need to think about locale at all. One of its more distinctive features lets database models built with SQLAlchemy or SQLModel, two common Python database tools, store translated versions of a field like a title or description directly, and read and write them like ordinary text. Behind the scenes it stores all languages for that field together and returns whichever one matches the current request's language, falling back to a default language if a translation is missing. The library intentionally does not try to translate technical validation error messages itself, that job is left to a companion package called fastkit-core, which builds on top of this one's translation function. This keeps fastkit-i18n small and free of extra dependencies for people who only need the translation pieces. Installation is a single pip command, and it needs Python 3.10 or newer. The database-model feature needs SQLAlchemy installed separately. It is released under the MIT license, meaning it can be freely used and modified, including in commercial projects, as long as the copyright notice is kept.

Copy-paste prompts

Prompt 1
Show me how to set up fastkit-i18n's LocaleMiddleware and TranslationManager in a FastAPI app.
Prompt 2
Explain how to make a SQLAlchemy model field translatable using TranslatableMixin.
Prompt 3
Walk me through the locale resolution order used by LocaleMiddleware.
Prompt 4
What is the known limitation of TranslatableMixin with model_dump(exclude_unset=True)?

Frequently asked questions

What is fastkit-i18n?

A Laravel-style i18n library for FastAPI that adds translation lookups, automatic locale detection, and translatable database model fields.

What language is fastkit-i18n written in?

Mainly Python. The stack also includes Python, FastAPI, SQLAlchemy.

What license does fastkit-i18n use?

MIT license: use, modify, and share freely, including commercially, as long as you keep the copyright notice.

How hard is fastkit-i18n to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is fastkit-i18n for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.