Files
weirsoe-party-protocol/lobby/i18n.py
DEV-bot 3253f4d343
All checks were successful
CI / test-and-quality (pull_request) Successful in 2m8s
CI / test-and-quality (push) Successful in 2m15s
feat(i18n): share lobby message catalog across frontend/backend
2026-03-01 15:07:47 +00:00

21 lines
606 B
Python

import json
from functools import lru_cache
from pathlib import Path
from django.http import JsonResponse
@lru_cache(maxsize=1)
def lobby_i18n_catalog() -> dict:
catalog_path = Path(__file__).resolve().parents[1] / "shared" / "i18n" / "lobby.json"
with catalog_path.open(encoding="utf-8") as handle:
return json.load(handle)
def lobby_i18n_errors() -> dict:
return lobby_i18n_catalog().get("backend", {}).get("error_codes", {})
def api_error(*, code: str, message: str, status: int) -> JsonResponse:
return JsonResponse({"error": message, "error_code": code}, status=status)