Files
Handy/scripts/check-model-language-coverage.ts
CJ Pais 0e5e9ca936 new onboarding (#2303)
* feat: new onboarding

* chore: remove new styling

* refactor: drop practice note insert workaround

* clean up welcome and perms

* lots of minor changes

* fix languages onboarding, and dropdown in app

* clean up table

* simplify lang

* better speed text

* fix dl speed + minor tweaks

* wip

* wip again

* transitions from demo to try

* simplify demo and beautify

* timing

* better demo/try it

* new all set page on try it

* pref languages, and demo shortcut tweaks

* wire traditional all the way through

* tweak search height

* clean up and fix obvious slop

* more code cleanup

* new models table, use on models page too

* shared model table for now

* better lang detection and fill for pref languages

* copy pass

* animation tweaks

* add translations for onboarding

* review fixes

* linux machine test fixes

* fix: consistent CJK font for language names on Windows/Linux

* fix: steady demo pointer and Tux taskbar mark on Linux

* fix: steady demo pointer and Tux taskbar mark on Linux

* fix stale nix

* center windows desktop

* trim comments

* review

* fix: custom app language menu, drop scrollbar arrows on Windows

* chore: trim AppLanguageMenu comments

* refactor: share model catalog, language picker and capture keys; drop unreachable a11y banner
2026-10-25 14:57:37 +08:00

58 lines
1.7 KiB
TypeScript

import catalog from "../src-tauri/src/catalog/catalog.json";
import { LANGUAGES, supportsLanguage } from "../src/lib/constants/languages.ts";
interface CatalogModel {
name: string;
role: string;
languages?: string[];
}
const failures: string[] = [];
// These code variants must share one saved language so switching model families
// keeps it. Mirrors `canonical_language_code` in src-tauri/src/managers/model.rs.
for (const [a, b] of [
["no", "nb"],
["tl", "fil"],
["iw", "he"],
["jw", "jv"],
]) {
if (!supportsLanguage([a], b) || !supportsLanguage([b], a)) {
failures.push(`Language code \`${a}\` must remain equivalent to \`${b}\``);
}
}
// Only transcription models reach the language picker; the catalog also lists
// the language-ID, VAD and diarization models transcribe.cpp publishes.
const transcriptionModels = (catalog.models as CatalogModel[]).filter(
(model) => model.role === "asr",
);
for (const model of transcriptionModels) {
for (const modelLanguage of model.languages ?? []) {
const matching = LANGUAGES.filter((language) =>
supportsLanguage([modelLanguage], language.code),
);
if (matching.length !== 1) {
const matchSummary =
matching.length === 0
? "no frontend language"
: `ambiguous languages: ${matching
.map((language) => language.code)
.join(", ")}`;
failures.push(`${model.name}: ${modelLanguage} (${matchSummary})`);
}
}
}
if (failures.length > 0) {
console.error("Model language coverage check failed:\n");
for (const failure of failures) console.error(` - ${failure}`);
process.exit(1);
}
console.log(
`Model language coverage: all catalog codes map to exactly one of ${LANGUAGES.length} frontend languages`,
);