mirror of
https://github.com/fancive/obsidian-parallel-reader.git
synced 2026-07-22 06:53:43 +00:00
fix(i18n): pass translated Cancel/OK labels to confirmRegenerateEditedCards
Adds cancelLabel and okLabel parameters with safe English defaults; caller in main.ts now passes plugin.t() values so button text matches UI language. https://claude.ai/code/session_012cK5rUGQvqkuxUZ59x7dLn
This commit is contained in:
parent
803e6468a1
commit
187c0d17b2
2 changed files with 16 additions and 4 deletions
8
main.ts
8
main.ts
|
|
@ -327,7 +327,13 @@ class ParallelReaderPlugin extends Plugin {
|
|||
}
|
||||
|
||||
confirmRegenerateEditedCards(): Promise<boolean> {
|
||||
return confirmRegenerateEditedCards(this.app, this.t('displayName'), this.t('confirmRegenerateEditedCards'));
|
||||
return confirmRegenerateEditedCards(
|
||||
this.app,
|
||||
this.t('displayName'),
|
||||
this.t('confirmRegenerateEditedCards'),
|
||||
this.t('editCardCancel'),
|
||||
this.t('editCardSave'),
|
||||
);
|
||||
}
|
||||
|
||||
addFileMenuItems(menu: ObsidianMenu, file: unknown) {
|
||||
|
|
|
|||
12
src/modal.ts
12
src/modal.ts
|
|
@ -4,7 +4,13 @@ import { type App, Modal } from 'obsidian';
|
|||
import type { CardPatch, PluginHost, ResolvedCard } from './types';
|
||||
import { addTextButton } from './ui-helpers';
|
||||
|
||||
export function confirmRegenerateEditedCards(app: App, title: string, message: string): Promise<boolean> {
|
||||
export function confirmRegenerateEditedCards(
|
||||
app: App,
|
||||
title: string,
|
||||
message: string,
|
||||
cancelLabel = 'Cancel',
|
||||
okLabel = 'OK',
|
||||
): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve) => {
|
||||
let settled = false;
|
||||
const settle = (value: boolean) => {
|
||||
|
|
@ -16,11 +22,11 @@ export function confirmRegenerateEditedCards(app: App, title: string, message: s
|
|||
modal.titleEl.setText(title);
|
||||
modal.contentEl.createEl('p', { text: message });
|
||||
const btnRow = modal.contentEl.createDiv({ cls: 'modal-button-container' });
|
||||
btnRow.createEl('button', { text: 'Cancel' }).addEventListener('click', () => {
|
||||
btnRow.createEl('button', { text: cancelLabel }).addEventListener('click', () => {
|
||||
modal.close();
|
||||
settle(false);
|
||||
});
|
||||
btnRow.createEl('button', { text: 'OK', cls: 'mod-cta' }).addEventListener('click', () => {
|
||||
btnRow.createEl('button', { text: okLabel, cls: 'mod-cta' }).addEventListener('click', () => {
|
||||
modal.close();
|
||||
settle(true);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue