π Adding Internationalization (i18n) in FastAPI If you're building a multi-lingual API with FastAPI, it's essential to support internationalization. In this guide, we'll use the python-i18n library — a simple and effective tool for managing translations in Python using JSON files. π¦ Step 1: Install python-i18n pip install python-i18n π Step 2: Create Locale Files Create a locales directory and add your language JSON files: locales/ ├── en.json └── fr.json en.json: { "greeting": "Hello" } fr.json: { "greeting": "Bonjour" } ⚙️ Step 3: Configure i18n in FastAPI import i18n from fastapi import FastAPI, Request app = FastAPI() # Load translation files i18n.load_path.append('locales') i18n.set('fallback', 'en') π Step 4: Detect Language from Request @app.middleware("http") async def add_language_to_request(request: Request, call_next): lang = request.headers.get(...
Theme: You don’t need to be a genius — just be generous and share your process. Core Message: “People can’t find you if you don’t let them see you.” Key Ideas: Share your process, not just the polished product. Be an amateur — open, curious, and always learning. Teach what you know , and build trust by showing up consistently. Don’t wait to be “ready” — sharing builds confidence and community. 10 Short Rules (Examples): You don’t have to be a genius. Think process, not product. Share something small every day. Stick around. Core Lesson: “Being good at something is no substitute for showing up and sharing it.”