Repository navigation
Localization
app/localization/
βββ translator.py β t(), get_user_language(), menu action detection
βββ translations.py β compatibility facade (re-exports translator)
βββ locales/
βββ en.py β English β single source of truth for all keys
βββ uk.py β Ukrainian
βββ no.py β Norwegian
βββ de.py β German
βββ es.py β Spanish
βββ fr.py β French
βββ it.py β Italian
βββ pl.py β Polish
from app.localization.translator import t
text = t("search_prompt", lang="uk")t(key, lang) looks up key in the locale for lang. Falls back to English if the key is missing in the target locale. lang is a 2-letter code stored per user in PostgreSQL.
t() is a god node in the knowledge graph β 72 edges, cross-community bridge between bot layer, admin tools, keyboards, tests, and all service-facing text.
- Add the key + English string to
app/localization/locales/en.py - Add translations to all 7 other locale files
- Run
python scripts/check_locale_coverage.pyβ reports missing keys per locale
en.py is the single source of truth. Non-English locales are allowed to be incomplete β missing keys fall back to English at runtime.
File: scripts/check_locale_coverage.py
CI gate. Reports:
uk: 48/48 keys (100%)
de: 47/48 keys (97.9%) β missing: search_no_results_extended
Run locally: python scripts/check_locale_coverage.py
Users select language via /language command or main menu. Selection saved to users.language column via set_user_language(pool, user_id, lang). Every subsequent t() call uses that stored value.
Default language for new users: English (en).