Add translation ids

This commit is contained in:
CRuiz
2025-01-22 13:41:18 -06:00
parent f2b667d75e
commit 73782c5389
15 changed files with 506 additions and 453 deletions

View File

@@ -8,7 +8,7 @@ import {
EVENT_SETTING_SAVED,
eventHub,
} from "../../common/events.ts";
import { $f, setLang } from "../../lib/src/common/i18n.ts";
import { $tf, setLang } from "../../lib/src/common/i18n.ts";
import { versionNumberString2Number } from "../../lib/src/string_and_binary/convert.ts";
import { cancelAllPeriodicTask, cancelAllTasks } from "octagonal-wheels/concurrency/task";
import { stopAllRunningProcessors } from "octagonal-wheels/concurrency/processor";
@@ -20,25 +20,16 @@ export class ModuleLiveSyncMain extends AbstractModule implements ICoreModule {
if (!(await this.core.$everyOnLayoutReady())) return;
eventHub.emitEvent(EVENT_LAYOUT_READY);
if (this.settings.suspendFileWatching || this.settings.suspendParseReplicationResult) {
const ANSWER_KEEP = "Keep LiveSync disabled";
const ANSWER_RESUME = "Resume and restart Obsidian";
const message = `Self-hosted LiveSync has been configured to ignore some events. Is this correct?
| Type | Status | Note |
|:---:|:---:|---|
| Storage Events | ${this.settings.suspendFileWatching ? "suspended" : "active"} | Every modification will be ignored |
| Database Events | ${this.settings.suspendParseReplicationResult ? "suspended" : "active"} | Every synchronised change will be postponed |
Do you want to resume them and restart Obsidian?
> [!DETAILS]-
> These flags are set by the plug-in while rebuilding, or fetching. If the process ends abnormally, it may be kept unintended.
> If you are not sure, you can try to rerun these processes. Make sure to back your vault up.
`;
const ANSWER_KEEP = $tf("moduleLiveSyncMain.optionKeepLiveSyncDisabled");
const ANSWER_RESUME = $tf("moduleLiveSyncMain.optionResumeAndRestart");
const message = $tf("moduleLiveSyncMain.msgScramEnabled", {
fileWatchingStatus: this.settings.suspendFileWatching ? "suspended" : "active",
parseReplicationStatus: this.settings.suspendParseReplicationResult ? "suspended" : "active"
});
if (
(await this.core.confirm.askSelectStringDialogue(message, [ANSWER_KEEP, ANSWER_RESUME], {
defaultAction: ANSWER_KEEP,
title: "Scram Enabled",
title: $tf("moduleLiveSyncMain.titleScramEnabled"),
})) == ANSWER_RESUME
) {
this.settings.suspendFileWatching = false;
@@ -56,11 +47,11 @@ Do you want to resume them and restart Obsidian?
if (!(await this.core.$everyOnFirstInitialize())) return;
await this.core.$$realizeSettingSyncMode();
fireAndForget(async () => {
this._log(`Additional safety scan..`, LOG_LEVEL_VERBOSE);
this._log($tf("moduleLiveSyncMain.logAdditionalSafetyScan"), LOG_LEVEL_VERBOSE);
if (!(await this.core.$allScanStat())) {
this._log(`Additional safety scan has failed on a module`, LOG_LEVEL_NOTICE);
this._log($tf("moduleLiveSyncMain.logSafetyScanFailed"), LOG_LEVEL_NOTICE);
} else {
this._log(`Additional safety scan completed`, LOG_LEVEL_VERBOSE);
this._log($tf("moduleLiveSyncMain.logSafetyScanCompleted"), LOG_LEVEL_VERBOSE);
}
});
}
@@ -80,9 +71,9 @@ Do you want to resume them and restart Obsidian?
this.$$wireUpEvents();
// debugger;
eventHub.emitEvent(EVENT_PLUGIN_LOADED, this.core);
this._log("loading plugin");
this._log($tf("moduleLiveSyncMain.logLoadingPlugin"));
if (!(await this.core.$everyOnloadStart())) {
this._log("Plugin initialisation was cancelled by a module", LOG_LEVEL_NOTICE);
this._log($tf("moduleLiveSyncMain.logPluginInitCancelled"), LOG_LEVEL_NOTICE);
return;
}
// this.addUIs();
@@ -91,10 +82,10 @@ Do you want to resume them and restart Obsidian?
//@ts-ignore
const packageVersion: string = PACKAGE_VERSION || "0.0.0";
this._log($f`Self-hosted LiveSync${" v"}${manifestVersion} ${packageVersion}`);
this._log($tf("moduleLiveSyncMain.logPluginVersion", { manifestVersion, packageVersion }));
await this.core.$$loadSettings();
if (!(await this.core.$everyOnloadAfterLoadSettings())) {
this._log("Plugin initialisation was cancelled by a module", LOG_LEVEL_NOTICE);
this._log($tf("moduleLiveSyncMain.logPluginInitCancelled"), LOG_LEVEL_NOTICE);
return;
}
const lsKey = "obsidian-live-sync-ver" + this.core.$$getVaultName();
@@ -102,7 +93,7 @@ Do you want to resume them and restart Obsidian?
const lastVersion = ~~(versionNumberString2Number(manifestVersion) / 1000);
if (lastVersion > this.settings.lastReadUpdates && this.settings.isConfigured) {
this._log($f`LiveSync has updated, please read the changelog!`, LOG_LEVEL_NOTICE);
this._log($tf("moduleLiveSyncMain.logReadChangelog"), LOG_LEVEL_NOTICE);
}
//@ts-ignore
@@ -117,7 +108,7 @@ Do you want to resume them and restart Obsidian?
this.settings.syncOnFileOpen = false;
this.settings.syncAfterMerge = false;
this.settings.periodicReplication = false;
this.settings.versionUpFlash = $f`LiveSync has been updated, In case of breaking updates, all automatic synchronization has been temporarily disabled. Ensure that all devices are up to date before enabling.`;
this.settings.versionUpFlash = $tf("moduleLiveSyncMain.logVersionUpdate");
await this.saveSettings();
}
localStorage.setItem(lsKey, `${VER}`);
@@ -148,7 +139,7 @@ Do you want to resume them and restart Obsidian?
}
await this.localDatabase.close();
}
this._log($f`unloading plugin`);
this._log($tf("moduleLiveSyncMain.logUnloadingPlugin"));
}
async $$realizeSettingSyncMode(): Promise<void> {