feat(subtitles): add local Japanese subtitle generation (#240)

This commit is contained in:
sudacode authored and GitHub committed 2026-09-15 21:43:11 -07:00
1 parent 6841a37a22
commit 2831e05124
90 files changed
+4934 -57

No files matched your search

+23
View File
@@ -92,6 +92,7 @@ function createEmptyShortcuts(): ConfiguredShortcuts {
openRuntimeOptions: null,
openJimaku: null,
openTsukihime: null,
openSubtitleGeneration: null,
openSessionHelp: null,
openControllerSelect: null,
openControllerDebug: null,
@@ -1591,6 +1592,28 @@ test('session binding: Ctrl+Alt+S dispatches subsync action locally', async () =
}
});
test('session binding: Ctrl+Shift+G dispatches subtitle generation with the sidebar closed', async () => {
const { handlers, testGlobals } = createKeyboardHandlerHarness();
try {
await handlers.setupMpvInputForwarding();
handlers.updateSessionBindings([
{
sourcePath: 'shortcuts.openSubtitleGeneration',
originalKey: 'Ctrl+Shift+G',
key: { code: 'KeyG', modifiers: ['ctrl', 'shift'] },
actionType: 'session-action',
actionId: 'openSubtitleGeneration',
},
]);
testGlobals.dispatchKeydown({ key: 'G', code: 'KeyG', ctrlKey: true, shiftKey: true });
assert.deepEqual(testGlobals.sessionActions, [
{ actionId: 'openSubtitleGeneration', payload: undefined },
]);
} finally {
testGlobals.restore();
}
});
test('session binding: Ctrl+Shift+J dispatches jimaku action locally', async () => {
const { handlers, testGlobals } = createKeyboardHandlerHarness();
+6
View File
@@ -15,6 +15,7 @@ export function createKeyboardHandlers(
handleRuntimeOptionsKeydown: (e: KeyboardEvent) => boolean;
handleCharacterDictionaryKeydown: (e: KeyboardEvent) => boolean;
handleSubsyncKeydown: (e: KeyboardEvent) => boolean;
handleSubtitleGenerationKeydown?: (e: KeyboardEvent) => boolean;
handleKikuKeydown: (e: KeyboardEvent) => boolean;
handleJimakuKeydown: (e: KeyboardEvent) => boolean;
handleTsukihimeKeydown: (e: KeyboardEvent) => boolean;
@@ -1102,6 +1103,11 @@ export function createKeyboardHandlers(
);
document.addEventListener('keydown', (e: KeyboardEvent) => {
if (ctx.state.subtitleGenerationModalOpen) {
options.handleSubtitleGenerationKeydown?.(e);
return;
}
if (ctx.state.mediaTimingReviewModalOpen) {
options.handleMediaTimingReviewKeydown(e);
return;