Add opt-in JLPT tagging flow

This commit is contained in:
2026-02-15 16:28:00 -08:00
parent ca2b7bb2fe
commit f492622a8b
27 changed files with 1116 additions and 38 deletions

View File

@@ -174,6 +174,7 @@ export const DEFAULT_CONFIG: ResolvedConfig = {
ffmpeg_path: "",
},
subtitleStyle: {
enableJlpt: false,
fontFamily:
"Noto Sans CJK JP Regular, Noto Sans CJK JP, Arial Unicode MS, Arial, sans-serif",
fontSize: 35,
@@ -183,6 +184,13 @@ export const DEFAULT_CONFIG: ResolvedConfig = {
backgroundColor: "rgba(54, 58, 79, 0.5)",
nPlusOneColor: "#c6a0f6",
knownWordColor: "#a6da95",
jlptColors: {
N1: "#ed8796",
N2: "#f5a97f",
N3: "#f9e2af",
N4: "#a6e3a1",
N5: "#8aadf4",
},
secondary: {
fontSize: 24,
fontColor: "#ffffff",
@@ -280,6 +288,13 @@ export const CONFIG_OPTION_REGISTRY: ConfigOptionRegistryEntry[] = [
defaultValue: DEFAULT_CONFIG.websocket.port,
description: "Built-in subtitle websocket server port.",
},
{
path: "subtitleStyle.enableJlpt",
kind: "boolean",
defaultValue: DEFAULT_CONFIG.subtitleStyle.enableJlpt,
description: "Enable JLPT vocabulary level underlines. "
+ "When disabled, JLPT tagging lookup and underlines are skipped.",
},
{
path: "ankiConnect.enabled",
kind: "boolean",

View File

@@ -442,6 +442,18 @@ export class ConfigService {
: {}),
},
};
const enableJlpt = asBoolean((src.subtitleStyle as { enableJlpt?: unknown }).enableJlpt);
if (enableJlpt !== undefined) {
resolved.subtitleStyle.enableJlpt = enableJlpt;
} else if ((src.subtitleStyle as { enableJlpt?: unknown }).enableJlpt !== undefined) {
warn(
"subtitleStyle.enableJlpt",
(src.subtitleStyle as { enableJlpt?: unknown }).enableJlpt,
resolved.subtitleStyle.enableJlpt,
"Expected boolean.",
);
}
}
if (isObject(src.ankiConnect)) {