Files
DeepTutor/web/lib/datetime.ts
Ruslan 4c6498b72a feat(i18n): add Ukrainian as a full interface and output language
Adds `uk` alongside `en` and `zh`: a complete `web/locales/uk/app.json`
(4009 keys), a Ukrainian CLI label set (102 keys), a Ukrainian quiz-judge
prompt, and the language directive that tells the model to answer in it.

Most of the diff is not the translation — it is the six independent
places that each decided, on their own, which languages exist. Every one
of them collapsed an unknown code to English *silently*, so picking
Ukrainian in Settings produced an English UI, English AI feedback and an
English chat reply, with nothing logged anywhere:

  * `services/settings/interface_settings._normalize_language` — the
    canonical normalizer; `interface.json` stored `uk`, the API returned
    `en`, and it looked like the setting had failed to save.
  * `agents/loop/prompt_blocks` — conflated two different things in one
    attribute: which prompt ASSETS exist (yaml ships `en`/`zh` only) and
    which language to ANSWER in (any). Split into `language` and
    `output_language`; the directive now takes the latter.
  * `api/routers/quiz_judge` — the supported set is now derived from
    `_JUDGE_SYSTEM_PROMPTS`, so a language cannot be advertised without a
    prompt or shipped without being advertised.
  * `web/i18n/init` — `normalizeLanguage`/`ensureLanguage`, plus a new
    exported `APP_LANGUAGES` that every picker maps over. The Settings
    toggle inlined `["en", "zh"]`, so a new locale was invisible there
    even once it existed.
  * `web/context/app-shell-storage` — held a second, private copy of the
    `AppLanguage` union; re-exported from `i18n/init` instead.
  * `runtime/banner` and `services/config/settings_spec` — the CLI wizard
    labels and the Settings language list.

Tool hints stay a per-language map from the API where only `en` is
guaranteed, so `ToolsSettingsSection` falls back instead of indexing a
missing key. Backend prompt yaml is still `en`/`zh`; Ukrainian uses the
English scaffolding with a Ukrainian output directive, which is what the
directive is for.

`tests/i18n/test_ukrainian_locale.py` pins each seam — locale key parity,
placeholder integrity, judge/prompt/normalizer coverage, and that the
Settings toggle maps over `APP_LANGUAGES` rather than a literal — so the
next language fails in CI rather than quietly in the UI.
2026-09-09 22:16:00 +03:00

28 lines
674 B
TypeScript

export type Language = "en" | "zh" | "uk";
export function getLocale(lang: Language): string {
if (lang === "zh") return "zh-CN";
if (lang === "uk") return "uk-UA";
return "en-US";
}
export function formatDate(
date: Date,
lang: Language,
options: Intl.DateTimeFormatOptions = {
year: "numeric",
month: "short",
day: "numeric",
},
): string {
return new Intl.DateTimeFormat(getLocale(lang), options).format(date);
}
export function formatTime(
date: Date,
lang: Language,
options: Intl.DateTimeFormatOptions = { hour: "2-digit", minute: "2-digit" },
): string {
return new Intl.DateTimeFormat(getLocale(lang), options).format(date);
}