Étape 1 : squelette du projet
- Monorepo backend/ + frontend/ + deploy/ - Backend FastAPI/SQLModel/Alembic/uv qui démarre (health check, config, i18n, base de test PostgreSQL, pytest) - docker-compose de développement (db + backend hot-reload) - Chaîne CI/CD GitHub Actions : lint + tests, build image, push GHCR, déploiement SSH sur le VPS à chaque push main - CLAUDE.md : vocabulaire du domaine, conventions, commandes Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017uUsRg7XzopkCPWimwg9ZM
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import json
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
|
||||
_LOCALE_DIR = Path(__file__).parent / "locales"
|
||||
DEFAULT_LOCALE = "fr"
|
||||
|
||||
|
||||
@lru_cache
|
||||
def _catalog(locale: str) -> dict[str, str]:
|
||||
path = _LOCALE_DIR / f"{locale}.json"
|
||||
return json.loads(path.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def t(key: str, locale: str = DEFAULT_LOCALE, **params: object) -> str:
|
||||
"""Traduit une clé. Aucun texte visible par l'utilisateur ne doit être
|
||||
écrit en dur ailleurs que dans les fichiers `locales/*.json`."""
|
||||
template = _catalog(locale).get(key, key)
|
||||
try:
|
||||
return template.format(**params)
|
||||
except (KeyError, IndexError):
|
||||
return template
|
||||
Reference in New Issue
Block a user