mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:29:49 +08:00
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.
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
export type ToolAvailabilityLanguage = "en" | "zh" | "uk";
|
|
|
|
export type ToolAvailabilityCopy = {
|
|
badge: string;
|
|
detail: string;
|
|
href?: string;
|
|
};
|
|
|
|
export function toolEffectiveEnabled(
|
|
savedEnabled: boolean,
|
|
available: boolean,
|
|
comingSoon: boolean,
|
|
): boolean {
|
|
return savedEnabled && available && !comingSoon;
|
|
}
|
|
|
|
export function toolAvailabilityCopy(
|
|
reason: string | null | undefined,
|
|
language: ToolAvailabilityLanguage,
|
|
): ToolAvailabilityCopy {
|
|
if (reason === "search_provider_not_configured") {
|
|
return language === "zh"
|
|
? {
|
|
badge: "未配置",
|
|
detail: "请先在搜索设置中选择提供商。DuckDuckGo 无需 API 密钥。",
|
|
href: "/settings#search",
|
|
}
|
|
: {
|
|
badge: "Not configured",
|
|
detail:
|
|
"Choose a provider in Search settings first. DuckDuckGo needs no API key.",
|
|
href: "/settings#search",
|
|
};
|
|
}
|
|
if (reason === "search_credentials_missing") {
|
|
return language === "zh"
|
|
? {
|
|
badge: "缺少凭证",
|
|
detail: "当前搜索提供商缺少所需凭证,请检查搜索设置。",
|
|
href: "/settings#search",
|
|
}
|
|
: {
|
|
badge: "Credentials missing",
|
|
detail:
|
|
"The selected search provider needs credentials. Check Search settings.",
|
|
href: "/settings#search",
|
|
};
|
|
}
|
|
return language === "zh"
|
|
? { badge: "暂不可用", detail: "该工具的运行服务当前不可用。" }
|
|
: {
|
|
badge: "Unavailable",
|
|
detail: "This tool's runtime service is unavailable.",
|
|
};
|
|
}
|