mirror of
https://github.com/fancive/obsidian-parallel-reader.git
synced 2026-07-22 06:53:43 +00:00
fix: localize batch prompt confirmation
Change-Id: I13b546785c5984a9d0cb5abaffa843f9ad7655d0
This commit is contained in:
parent
2bf4e86451
commit
3bdd6d67c6
4 changed files with 16 additions and 3 deletions
7
main.ts
7
main.ts
|
|
@ -541,7 +541,12 @@ class ParallelReaderPlugin extends Plugin {
|
|||
new Notice(this.t('batchAlreadyRunning'));
|
||||
return;
|
||||
}
|
||||
const folderPath = await promptForBatchFolder(this.app, this.t('batchSelectFolder'), this.t('batchFolderPrompt'));
|
||||
const folderPath = await promptForBatchFolder(
|
||||
this.app,
|
||||
this.t('batchSelectFolder'),
|
||||
this.t('batchFolderPrompt'),
|
||||
this.t('batchFolderConfirm'),
|
||||
);
|
||||
if (folderPath === null) return;
|
||||
const validation = validateBatchFolderInput(folderPath, (path) => {
|
||||
const target = this.app.vault.getAbstractFileByPath(path);
|
||||
|
|
|
|||
|
|
@ -104,7 +104,12 @@ export function requestBatchCancel(state: BatchRunState | null): boolean {
|
|||
return true;
|
||||
}
|
||||
|
||||
export function promptForBatchFolder(app: App, selectText: string, promptText: string): Promise<string | null> {
|
||||
export function promptForBatchFolder(
|
||||
app: App,
|
||||
selectText: string,
|
||||
promptText: string,
|
||||
confirmText: string,
|
||||
): Promise<string | null> {
|
||||
return new Promise<string | null>((resolve) => {
|
||||
const modal = new Modal(app);
|
||||
modal.onOpen = () => {
|
||||
|
|
@ -118,7 +123,7 @@ export function promptForBatchFolder(app: App, selectText: string, promptText: s
|
|||
modal.close();
|
||||
}
|
||||
});
|
||||
modal.contentEl.createEl('button', { text: 'OK' }).addEventListener('click', () => {
|
||||
modal.contentEl.createEl('button', { text: confirmText }).addEventListener('click', () => {
|
||||
resolve(input.value.trim());
|
||||
modal.close();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ export const STRINGS: Record<string, Record<string, string>> = {
|
|||
cmdBatchGenerate: '批量生成对照笔记(当前文件夹)',
|
||||
batchSelectFolder: '请输入要批量处理的文件夹路径(留空为 Vault 根目录)',
|
||||
batchFolderPrompt: '文件夹路径',
|
||||
batchFolderConfirm: '确定',
|
||||
batchAlreadyRunning: '批量生成正在运行',
|
||||
batchCancelRequested: '已请求取消批量生成;当前文件结束后停止',
|
||||
batchInvalidFolderInput: '文件夹路径无效:{path}',
|
||||
|
|
@ -332,6 +333,7 @@ export const STRINGS: Record<string, Record<string, string>> = {
|
|||
cmdBatchGenerate: 'Batch generate parallel notes (current folder)',
|
||||
batchSelectFolder: 'Enter the folder path to batch-process (leave blank for Vault root)',
|
||||
batchFolderPrompt: 'Folder path',
|
||||
batchFolderConfirm: 'OK',
|
||||
batchAlreadyRunning: 'Batch generation is already running',
|
||||
batchCancelRequested: 'Batch cancellation requested; it will stop after the current note',
|
||||
batchInvalidFolderInput: 'Invalid folder path: {path}',
|
||||
|
|
|
|||
|
|
@ -31,5 +31,6 @@ assert.strictEqual(
|
|||
t.translate({ uiLanguage: 'en' }, 'confirmExportOverwrite', { path: 'Reading/A.md' }),
|
||||
'Export file already exists: Reading/A.md\nOverwrite it?',
|
||||
);
|
||||
assert.strictEqual(t.translate({ uiLanguage: 'zh' }, 'batchFolderConfirm'), '确定');
|
||||
|
||||
console.log('i18n tests passed');
|
||||
|
|
|
|||
Loading…
Reference in a new issue