3 - Translated settings and common phrases.

This commit is contained in:
Caleb Campbell
2025-12-27 10:57:12 +11:00
parent d01f4bec2e
commit 2bcf3cb980
10 changed files with 184 additions and 121 deletions

View File

@@ -0,0 +1,7 @@
import { CommonLabels } from '../models';
export const COMMON_LABELS: CommonLabels = {
folderDoesNotExist: 'Ordner exsistiert nicht in dem Verzeichnis:',
settingsNotConfigured:
'Die Einstellungen der Erweiterung "Lokale Parallelstellen" (Local Bible Ref) sind nicht eingerichtet. Bitte legen Sie den Pfad für die Bibeln fest, bevor Sie versuchen, auf Bibelabschnitte zu verweisen.',
};

View File

@@ -1,7 +1,9 @@
import { BOOKS } from './books'; import { BOOKS } from './books';
import { SETTINGS } from './settings'; import { COMMON_LABELS } from './common-labels';
import { SETTINGS_LABELS } from './settings-labels';
export const DE = { export const DE = {
BOOKS, BOOKS,
SETTINGS, COMMON: COMMON_LABELS,
SETTINGS: SETTINGS_LABELS,
}; };

View File

@@ -0,0 +1,86 @@
import { PassageFormat } from 'src/passage-reference';
import { SettingsLabels } from '../models';
import { QuoteReferencePosition } from 'src/settings';
export const SETTINGS_LABELS: SettingsLabels = {
required: {
name: 'Erforderliche Einstellungen',
controls: {
biblesPath: {
name: 'Bibeldateien',
description: 'Pfad zu den Bibeldateien',
placeholder: 'z.B. Dateien/Bibel',
},
},
},
optional: {
name: 'Optionale Einstellungen',
controls: {
defaultVersion: {
name: 'Standardversion',
description:
'Welche Bibelversion soll als Standardversion verwendet werden? Diese Abkürzung muss mit einem Ordner in dem oben angegebenen Pfad übereinstimmen.',
placeholder: 'z.B. Schl2000',
},
defaultPassageFormat: {
name: 'Standard Bibelstellenformat',
description:
'Welches Markdownformat soll für einen Bibelstelle standardmäßig ausgewählt werden?',
options: {
[PassageFormat.Manuscript]: 'Manuskript',
[PassageFormat.Paragraph]: 'Abschnitt',
[PassageFormat.Quote]: 'Zitat',
[PassageFormat.Callout]: 'Callout',
},
},
bibleFormat: {
name: 'Bibelformat',
description:
'Der Formatierungsstil, den Sie für Ihre Vault-Bibeln verwenden. Local Bible Ref benötigt diesen, um Textpassagen korrekt zu analysieren.',
},
},
},
quoteFormat: {
name: 'Einstellungen für das Angebotsformat',
description: 'Einstellungen für das Zitatpassageformat.',
controls: {
includeReference: {
name: 'Referenz angeben',
description: 'Ob ein Verweis auf die Passage aufgenommen werden soll.',
},
referencePosition: {
name: 'Referenzposition',
description:
'Die Position der Bezugnahme im Verhältnis zum zitierten Text.',
options: {
[QuoteReferencePosition.Beginning]: 'Anfang',
[QuoteReferencePosition.End]: 'Ende',
},
},
linkToPassage: {
name: 'Link zur Passage',
description:
'Ob Sie den Verweis auf die Passage in Ihrer Tresorbibel verlinken möchten.',
},
},
},
calloutFormat: {
name: 'Einstellungen für das Callout-Format',
description: 'Einstellungen für das Format des Callout-Passages.',
controls: {
calloutType: {
name: 'Callout-Typ',
description:
'Die Art des Verweises, der für die Passage verwendet werden soll.',
},
linkToPassage: {
name: 'Link zur Passage',
description:
'Ob Sie den Verweis auf die Passage in Ihrer Tresorbibel verlinken möchten.',
},
},
},
};

View File

@@ -1,72 +0,0 @@
import { SettingsLabels } from '../models';
export const SETTINGS: SettingsLabels = {
required: {
name: 'Required Settings',
controls: {
biblesPath: {
name: 'Bible pathen',
description: 'The path to the folder containing your bibles.',
placeholder: 'e.g. Data/Bibles',
},
},
},
optional: {
name: 'Optional Settings',
controls: {
defaultVersion: {
name: 'Default version',
description:
'The version to use by default - shorthand. This should correspond to a folder in the bibles folder selected above.',
placeholder: 'e.g. NIV',
},
defaultPassageFormat: {
name: 'Default passage format',
description: 'The markdown format to use for passages by default.',
},
bibleFormat: {
name: 'Bible format',
description:
'The formatting style you use for your vault bibles. Local Bible Ref relies on this to parse passages correctly.',
},
},
},
quoteFormat: {
name: 'Quote Format Settings',
description: 'Settings for the quote passage format.',
controls: {
includeReference: {
name: 'Include reference',
description: 'Whether to include a reference to the passage.',
},
referencePosition: {
name: 'Reference position',
description:
'The position of the reference in relation to the quoted text.',
},
linkToPassage: {
name: 'Link to passage',
description:
'Whether to link the reference to the passage in your vault Bible.',
},
},
},
calloutFormat: {
name: 'Callout Format Settings',
description: 'Settings for the callout passage format.',
controls: {
calloutType: {
name: 'Callout type',
description: 'The type of callout to use for the passage.',
},
linkToPassage: {
name: 'Link to passage',
description:
'Whether to link the reference to the passage in your vault Bible.',
},
},
},
};

View File

@@ -0,0 +1,7 @@
import { CommonLabels } from '../models';
export const COMMON_LABELS: CommonLabels = {
folderDoesNotExist: "Folder doesn't exist at path:",
settingsNotConfigured:
'Local Bible Ref settings are not configured. Please set the bibles path before attempting to reference passages.',
};

View File

@@ -1,7 +1,9 @@
import { BOOKS } from './books'; import { BOOKS } from './books';
import { SETTINGS } from './settings'; import { COMMON_LABELS } from './common-labels';
import { SETTINGS_LABELS } from './settings-labels';
export const EN = { export const EN = {
BOOKS, BOOKS,
SETTINGS, COMMON: COMMON_LABELS,
SETTINGS: SETTINGS_LABELS,
}; };

View File

@@ -1,6 +1,8 @@
import { PassageFormat } from 'src/passage-reference';
import { SettingsLabels } from '../models'; import { SettingsLabels } from '../models';
import { QuoteReferencePosition } from 'src/settings';
export const SETTINGS: SettingsLabels = { export const SETTINGS_LABELS: SettingsLabels = {
required: { required: {
name: 'Required Settings', name: 'Required Settings',
controls: { controls: {
@@ -24,6 +26,12 @@ export const SETTINGS: SettingsLabels = {
defaultPassageFormat: { defaultPassageFormat: {
name: 'Default passage format', name: 'Default passage format',
description: 'The markdown format to use for passages by default.', description: 'The markdown format to use for passages by default.',
options: {
[PassageFormat.Manuscript]: 'Manuscript',
[PassageFormat.Paragraph]: 'Paragraph',
[PassageFormat.Quote]: 'Quote',
[PassageFormat.Callout]: 'Callout',
},
}, },
bibleFormat: { bibleFormat: {
name: 'Bible format', name: 'Bible format',
@@ -45,6 +53,10 @@ export const SETTINGS: SettingsLabels = {
name: 'Reference position', name: 'Reference position',
description: description:
'The position of the reference in relation to the quoted text.', 'The position of the reference in relation to the quoted text.',
options: {
[QuoteReferencePosition.Beginning]: 'Beginning',
[QuoteReferencePosition.End]: 'End',
},
}, },
linkToPassage: { linkToPassage: {
name: 'Link to passage', name: 'Link to passage',

View File

@@ -1,22 +1,37 @@
import { PassageFormat } from 'src/passage-reference';
import { QuoteReferencePosition } from 'src/settings';
export interface Book { export interface Book {
id: string; id: string;
name: string; name: string;
aliases: string[]; aliases: string[];
} }
export interface CommonLabels {
folderDoesNotExist: string;
settingsNotConfigured: string;
}
export interface SettingsLabels { export interface SettingsLabels {
required: { required: {
name: string; name: string;
controls: { controls: {
biblesPath: ControlWithPlaceholder; biblesPath: TextControl;
}; };
}; };
optional: { optional: {
name: string; name: string;
controls: { controls: {
defaultVersion: ControlWithPlaceholder; defaultVersion: TextControl;
defaultPassageFormat: Control; defaultPassageFormat: Control & {
options: {
[PassageFormat.Manuscript]: string;
[PassageFormat.Paragraph]: string;
[PassageFormat.Quote]: string;
[PassageFormat.Callout]: string;
};
};
bibleFormat: Control; bibleFormat: Control;
}; };
}; };
@@ -26,7 +41,12 @@ export interface SettingsLabels {
description: string; description: string;
controls: { controls: {
includeReference: Control; includeReference: Control;
referencePosition: Control; referencePosition: Control & {
options: {
[QuoteReferencePosition.Beginning]: string;
[QuoteReferencePosition.End]: string;
};
};
linkToPassage: Control; linkToPassage: Control;
}; };
}; };
@@ -46,6 +66,6 @@ interface Control {
description: string; description: string;
} }
interface ControlWithPlaceholder extends Control { interface TextControl extends Control {
placeholder: string; placeholder: string;
} }

View File

@@ -16,11 +16,14 @@ import { SettingsLabels } from './i18n/models';
import { I18N } from './i18n'; import { I18N } from './i18n';
// STILL TODO: // STILL TODO:
// - Need to add a 'common' labels internationalization file for non-settings labels. (e.g. notices)
// - Need to sort out books in PassageReference to use I18N. // - Need to sort out books in PassageReference to use I18N.
// - Need to sort out smallcaps 'Lord' in German.
export default class LocalBibleRefSettingTab extends PluginSettingTab { export default class LocalBibleRefSettingTab extends PluginSettingTab {
private readonly hiddenClass = 'local-bible-ref-hidden';
private plugin: LocalBibleRefPlugin; private plugin: LocalBibleRefPlugin;
private folderDoesNotExistText = '';
private settingsLabels: SettingsLabels; private settingsLabels: SettingsLabels;
constructor(app: App, plugin: LocalBibleRefPlugin) { constructor(app: App, plugin: LocalBibleRefPlugin) {
@@ -29,10 +32,12 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
switch (getLanguage()) { switch (getLanguage()) {
case 'de': case 'de':
this.folderDoesNotExistText = I18N.DE.COMMON.folderDoesNotExist;
this.settingsLabels = I18N.DE.SETTINGS; this.settingsLabels = I18N.DE.SETTINGS;
break; break;
case 'en': case 'en':
default: default:
this.folderDoesNotExistText = I18N.EN.COMMON.folderDoesNotExist;
this.settingsLabels = I18N.EN.SETTINGS; this.settingsLabels = I18N.EN.SETTINGS;
break; break;
} }
@@ -57,13 +62,9 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
.onChange(async (value) => { .onChange(async (value) => {
// toggle visibility of default version setting // toggle visibility of default version setting
if (value) { if (value) {
defaultVersionSetting.settingEl.removeClass( defaultVersionSetting.settingEl.removeClass(this.hiddenClass);
'local-bible-ref-hidden'
);
} else { } else {
defaultVersionSetting.settingEl.addClass( defaultVersionSetting.settingEl.addClass(this.hiddenClass);
'local-bible-ref-hidden'
);
( (
defaultVersionSetting.components[0] as TextComponent defaultVersionSetting.components[0] as TextComponent
).inputEl.value = ''; ).inputEl.value = '';
@@ -78,7 +79,8 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
biblesPathTimeout = window.setTimeout(async () => { biblesPathTimeout = window.setTimeout(async () => {
if (!path) return; if (!path) return;
const exists = this.app.vault.getFolderByPath(path); const exists = this.app.vault.getFolderByPath(path);
if (!exists) new Notice(`Folder doesn't exist at path: ${path}.`); if (!exists)
new Notice(`${this.folderDoesNotExistText} ${path}.`);
}, 1000); }, 1000);
}); });
@@ -105,7 +107,8 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
const exists = this.app.vault.getFolderByPath( const exists = this.app.vault.getFolderByPath(
normalizePath(path) normalizePath(path)
); );
if (!exists) new Notice(`Folder doesn't exist at path: ${path}.`); if (!exists)
new Notice(`${this.folderDoesNotExistText} ${path}.`);
}, 1000); }, 1000);
}); });
@@ -113,9 +116,9 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
}); });
if (this.plugin.settings.biblesPath) { if (this.plugin.settings.biblesPath) {
defaultVersionSetting.settingEl.removeClass('local-bible-ref-hidden'); defaultVersionSetting.settingEl.removeClass(this.hiddenClass);
} else { } else {
defaultVersionSetting.settingEl.addClass('local-bible-ref-hidden'); defaultVersionSetting.settingEl.addClass(this.hiddenClass);
} }
new Setting(containerEl) new Setting(containerEl)
@@ -123,12 +126,7 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
.setDesc(optional.controls.defaultPassageFormat.description) .setDesc(optional.controls.defaultPassageFormat.description)
.addDropdown((dropdown) => .addDropdown((dropdown) =>
dropdown dropdown
.addOptions({ .addOptions(optional.controls.defaultPassageFormat.options)
manuscript: 'Manuscript',
paragraph: 'Paragraph',
quote: 'Quote',
callout: 'Callout',
})
.setValue(this.plugin.settings.defaultPassageFormat) .setValue(this.plugin.settings.defaultPassageFormat)
.onChange(async (value) => { .onChange(async (value) => {
this.plugin.settings.defaultPassageFormat = value as PassageFormat; this.plugin.settings.defaultPassageFormat = value as PassageFormat;
@@ -166,17 +164,11 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
.onChange(async (value) => { .onChange(async (value) => {
// toggle visibility of other paragraph reference settings // toggle visibility of other paragraph reference settings
if (value) { if (value) {
quoteRefPositionSetting.settingEl.removeClass( quoteRefPositionSetting.settingEl.removeClass(this.hiddenClass);
'local-bible-ref-hidden' quoteRefLinkSetting.settingEl.removeClass(this.hiddenClass);
);
quoteRefLinkSetting.settingEl.removeClass(
'local-bible-ref-hidden'
);
} else { } else {
quoteRefPositionSetting.settingEl.addClass( quoteRefPositionSetting.settingEl.addClass(this.hiddenClass);
'local-bible-ref-hidden' quoteRefLinkSetting.settingEl.addClass(this.hiddenClass);
);
quoteRefLinkSetting.settingEl.addClass('local-bible-ref-hidden');
} }
this.plugin.settings.quote.includeReference = value; this.plugin.settings.quote.includeReference = value;
@@ -189,10 +181,7 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
.setDesc(quoteFormat.controls.referencePosition.description) .setDesc(quoteFormat.controls.referencePosition.description)
.addDropdown((dropdown) => .addDropdown((dropdown) =>
dropdown dropdown
.addOptions({ .addOptions(quoteFormat.controls.referencePosition.options)
beginning: 'Beginning',
end: 'End',
})
.setValue(this.plugin.settings.quote.referencePosition) .setValue(this.plugin.settings.quote.referencePosition)
.onChange(async (value) => { .onChange(async (value) => {
this.plugin.settings.quote.referencePosition = this.plugin.settings.quote.referencePosition =
@@ -214,11 +203,11 @@ export default class LocalBibleRefSettingTab extends PluginSettingTab {
); );
if (this.plugin.settings.quote.includeReference) { if (this.plugin.settings.quote.includeReference) {
quoteRefPositionSetting.settingEl.removeClass('local-bible-ref-hidden'); quoteRefPositionSetting.settingEl.removeClass(this.hiddenClass);
quoteRefLinkSetting.settingEl.removeClass('local-bible-ref-hidden'); quoteRefLinkSetting.settingEl.removeClass(this.hiddenClass);
} else { } else {
quoteRefPositionSetting.settingEl.addClass('local-bible-ref-hidden'); quoteRefPositionSetting.settingEl.addClass(this.hiddenClass);
quoteRefLinkSetting.settingEl.addClass('local-bible-ref-hidden'); quoteRefLinkSetting.settingEl.addClass(this.hiddenClass);
} }
new Setting(containerEl) new Setting(containerEl)

View File

@@ -5,6 +5,7 @@ import {
EditorSuggest, EditorSuggest,
EditorSuggestContext, EditorSuggestContext,
EditorSuggestTriggerInfo, EditorSuggestTriggerInfo,
getLanguage,
normalizePath, normalizePath,
Notice, Notice,
TFile, TFile,
@@ -13,14 +14,26 @@ import {
import { BibleFormat } from './local-bible-ref-setting-tab'; import { BibleFormat } from './local-bible-ref-setting-tab';
import PassageReference, { PassageFormat } from './passage-reference'; import PassageReference, { PassageFormat } from './passage-reference';
import LocalBibleRefSettings, { QuoteReferencePosition } from './settings'; import LocalBibleRefSettings, { QuoteReferencePosition } from './settings';
import { I18N } from './i18n';
export default class PassageSuggest extends EditorSuggest<PassageSuggestion> { export default class PassageSuggest extends EditorSuggest<PassageSuggestion> {
private settings: LocalBibleRefSettings; private settings: LocalBibleRefSettings;
private settingsNotConfiguredText = '';
private noSettingsNotice: Notice; private noSettingsNotice: Notice;
constructor(app: App, settings: LocalBibleRefSettings) { constructor(app: App, settings: LocalBibleRefSettings) {
super(app); super(app);
this.settings = settings; this.settings = settings;
switch (getLanguage()) {
case 'de':
this.settingsNotConfiguredText = I18N.DE.COMMON.settingsNotConfigured;
break;
case 'en':
default:
this.settingsNotConfiguredText = I18N.EN.COMMON.settingsNotConfigured;
break;
}
} }
onTrigger( onTrigger(
@@ -35,10 +48,7 @@ export default class PassageSuggest extends EditorSuggest<PassageSuggestion> {
// if no settings, alert user // if no settings, alert user
if (!this.settings.biblesPath) { if (!this.settings.biblesPath) {
if (!this.noSettingsNotice?.messageEl.isShown()) { if (!this.noSettingsNotice?.messageEl.isShown()) {
const noticeText = const noticeText = this.settingsNotConfiguredText;
'Local Bible Ref settings are not ' +
'configured. Please set the bibles path before ' +
'attempting to reference passages.';
this.noSettingsNotice = new Notice(noticeText); this.noSettingsNotice = new Notice(noticeText);
} }