Files
ajp_anton 8ec3cde4f2
Build custom container images / build (map[base_image:php:8-fpm-alpine build_args:PHP_VERSION=8 context:php8-pgsql fingerprint_command:{ apk info -v | LC_ALL=C sort; find /usr/local/lib/php/extensions /usr/local/etc/php/conf.d -type f -exec sha256sum {} + | LC_ALL=C sort; } name:ph… (push) Successful in 48s
Build custom container images / build (map[base_image:postgres:18 build_args:PG_VERSION=18 POSTGIS_VERSION=3 VCHORD_VERSION=0.5.3 context:postgres fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; find /usr/lib/postgresql -type f -exec sha256su… (push) Successful in 55s
Build custom container images / build (map[base_image:python:3 build_args:PYTHON_VERSION=3 context:python-tools fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; } name:python-tools oci_labels:org.opencontainers.ima… (push) Successful in 54s
Build custom container images / build (map[base_image:python:3.12-slim build_args:PYTHON_VERSION=3.12-slim context:linkki-tiedotus fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; } name:linkki-tiedotus oci_labels:… (push) Successful in 39s
Add Linkki broadcast image
2026-08-19 20:51:26 +00:00

43 lines
1.5 KiB
Python

import json
from pathlib import Path
from webapp.auth import SUPPORTED_UI_LANGUAGES, normalize_translation_language
from webapp.config import ConfigFileError
TRANSLATIONS_DIR = Path(__file__).resolve().parent / "translations"
TRANSLATION_CATALOG_FILE = TRANSLATIONS_DIR / "catalog.json"
def load_translations(language: str) -> dict:
normalized = normalize_translation_language(language)
catalog = load_translation_catalog()
merged: dict[str, object] = {}
for key, translations in catalog.items():
if not isinstance(translations, dict):
continue
english_value = translations.get("en")
localized_value = translations.get(normalized)
if localized_value not in (None, ""):
merged[key] = localized_value
elif english_value is not None:
merged[key] = english_value
return merged
def load_translation_catalog() -> dict:
if not TRANSLATION_CATALOG_FILE.exists():
return {}
try:
payload = json.loads(TRANSLATION_CATALOG_FILE.read_text(encoding="utf-8"))
except json.JSONDecodeError as error:
detail = f"Invalid JSON: {error.msg}"
if "Invalid control character" in error.msg:
detail += " JSON strings cannot contain raw line breaks; use \\n instead."
raise ConfigFileError(TRANSLATION_CATALOG_FILE, detail) from error
return payload if isinstance(payload, dict) else {}
def language_options() -> list[dict[str, str]]:
return [{"code": code, "label_key": f"ui_language.{code}"} for code in SUPPORTED_UI_LANGUAGES]