@@ -12,8 +12,10 @@ import type { LiveSyncCore } from "../../main.ts";
1212import FetchEverything from "../features/SetupWizard/dialogs/FetchEverything.svelte" ;
1313import RebuildEverything from "../features/SetupWizard/dialogs/RebuildEverything.svelte" ;
1414import { extractObject } from "octagonal-wheels/object" ;
15+ import type { FetchEverythingResult , RebuildEverythingResult } from "../../modules/features/SetupWizard/resultTypes" ;
1516import { SvelteDialogManagerBase } from "@lib/UI/svelteDialog.ts" ;
1617import type { ServiceContext } from "@lib/services/base/ServiceBase.ts" ;
18+ import { $msg } from "@lib/common/i18n.ts" ;
1719
1820export class ModuleRedFlag extends AbstractModule {
1921 async isFlagFileExist ( path : string ) {
@@ -72,7 +74,7 @@ export class ModuleRedFlag extends AbstractModule {
7274 if ( await this . adjustSettingToRemote ( config ) ) {
7375 config = this . core . settings ;
7476 } else {
75- this . _log ( "Remote configuration not applied." , LOG_LEVEL_NOTICE ) ;
77+ this . _log ( $msg ( "RedFlag.FetchRemoteConfig.NotApplied" ) , LOG_LEVEL_NOTICE ) ;
7678 }
7779 console . debug ( config ) ;
7880 }
@@ -84,19 +86,19 @@ export class ModuleRedFlag extends AbstractModule {
8486 */
8587 async adjustSettingToRemote ( config : ObsidianLiveSyncSettings ) {
8688 // Fetch remote configuration unless prevented.
87- const SKIP_FETCH = "Skip and proceed " ;
88- const RETRY_FETCH = "Retry (recommended) " ;
89+ const SKIP_FETCH = "RedFlag.FetchRemoteConfig.Buttons.SkipAndProceed " ;
90+ const RETRY_FETCH = "RedFlag.FetchRemoteConfig.Buttons. Retry" ;
8991 let canProceed = false ;
9092 do {
9193 const remoteTweaks = await this . services . tweakValue . fetchRemotePreferred ( config ) ;
9294 if ( ! remoteTweaks ) {
9395 const choice = await this . core . confirm . askSelectStringDialogue (
94- "Could not fetch configuration from remote. If you are new to the Self-hosted LiveSync, this might be expected. If not, you should check your network or server settings." ,
96+ $msg ( "RedFlag.FetchRemoteConfig.FailedMessage" ) ,
9597 [ SKIP_FETCH , RETRY_FETCH ] as const ,
9698 {
9799 defaultAction : RETRY_FETCH ,
98100 timeout : 0 ,
99- title : "Fetch Remote Configuration Failed" ,
101+ title : $msg ( "RedFlag.FetchRemoteConfig.FailedTitle" ) ,
100102 }
101103 ) ;
102104 if ( choice === SKIP_FETCH ) {
@@ -109,13 +111,10 @@ export class ModuleRedFlag extends AbstractModule {
109111 return ( config as any ) [ key ] !== value ;
110112 } ) ;
111113 if ( differentItems . length === 0 ) {
112- this . _log (
113- "Remote configuration matches local configuration. No changes applied." ,
114- LOG_LEVEL_NOTICE
115- ) ;
114+ this . _log ( $msg ( "RedFlag.FetchRemoteConfig.MatchesLocal" ) , LOG_LEVEL_NOTICE ) ;
116115 } else {
117116 await this . core . confirm . askSelectStringDialogue (
118- "Your settings differed slightly from the server's. The plug-in has supplemented the incompatible parts with the server settings!" ,
117+ $msg ( "RedFlag.FetchRemoteConfig.SettingsDiffered" ) ,
119118 [ "OK" ] as const ,
120119 {
121120 defaultAction : "OK" ,
@@ -130,7 +129,7 @@ export class ModuleRedFlag extends AbstractModule {
130129 } satisfies ObsidianLiveSyncSettings ;
131130 this . core . settings = config ;
132131 await this . core . services . setting . saveSettingData ( ) ;
133- this . _log ( "Remote configuration applied." , LOG_LEVEL_NOTICE ) ;
132+ this . _log ( $msg ( "RedFlag.FetchRemoteConfig.Applied" ) , LOG_LEVEL_NOTICE ) ;
134133 canProceed = true ;
135134 return this . core . settings ;
136135 }
@@ -155,12 +154,12 @@ export class ModuleRedFlag extends AbstractModule {
155154 const result = await proc ( ) ;
156155 return result ;
157156 } catch ( ex ) {
158- this . _log ( "Error during vault initialisation process." , LOG_LEVEL_NOTICE ) ;
157+ this . _log ( $msg ( "RedFlag.Log.VaultInitialisationProcessError" ) , LOG_LEVEL_NOTICE ) ;
159158 this . _log ( ex , LOG_LEVEL_VERBOSE ) ;
160159 return false ;
161160 }
162161 } catch ( ex ) {
163- this . _log ( "Error during vault initialisation." , LOG_LEVEL_NOTICE ) ;
162+ this . _log ( $msg ( "RedFlag.Log.VaultInitialisationError" ) , LOG_LEVEL_NOTICE ) ;
164163 this . _log ( ex , LOG_LEVEL_VERBOSE ) ;
165164 return false ;
166165 } finally {
@@ -177,10 +176,10 @@ export class ModuleRedFlag extends AbstractModule {
177176 * @returns true if can be continued, false if app restart is needed.
178177 */
179178 async onRebuildEverythingScheduled ( ) {
180- const method = await this . dialogManager . openWithExplicitCancel ( RebuildEverything ) ;
179+ const method = await this . dialogManager . openWithExplicitCancel < RebuildEverythingResult , undefined > ( RebuildEverything ) ;
181180 if ( method === "cancelled" ) {
182181 // Clean up the flag file and restart the app.
183- this . _log ( "Rebuild everything cancelled by user." , LOG_LEVEL_NOTICE ) ;
182+ this . _log ( $msg ( "RedFlag.Log.RebuildEverythingCancelled" ) , LOG_LEVEL_NOTICE ) ;
184183 await this . cleanupRebuildFlag ( ) ;
185184 this . services . appLifecycle . performRestart ( ) ;
186185 return false ;
@@ -190,7 +189,7 @@ export class ModuleRedFlag extends AbstractModule {
190189 return await this . processVaultInitialisation ( async ( ) => {
191190 await this . core . rebuilder . $rebuildEverything ( ) ;
192191 await this . cleanupRebuildFlag ( ) ;
193- this . _log ( "Rebuild everything operation completed." , LOG_LEVEL_NOTICE ) ;
192+ this . _log ( $msg ( "RedFlag.Log.RebuildEverythingCompleted" ) , LOG_LEVEL_NOTICE ) ;
194193 return true ;
195194 } ) ;
196195 }
@@ -199,9 +198,9 @@ export class ModuleRedFlag extends AbstractModule {
199198 * @returns true if can be continued, false if app restart is needed.
200199 */
201200 async onFetchAllScheduled ( ) {
202- const method = await this . dialogManager . openWithExplicitCancel ( FetchEverything ) ;
201+ const method = await this . dialogManager . openWithExplicitCancel < FetchEverythingResult , undefined > ( FetchEverything ) ;
203202 if ( method === "cancelled" ) {
204- this . _log ( "Fetch everything cancelled by user." , LOG_LEVEL_NOTICE ) ;
203+ this . _log ( $msg ( "RedFlag.Log.FetchEverythingCancelled" ) , LOG_LEVEL_NOTICE ) ;
205204 // Clean up the flag file and restart the app.
206205 await this . cleanupFetchAllFlag ( ) ;
207206 this . services . appLifecycle . performRestart ( ) ;
@@ -246,7 +245,7 @@ export class ModuleRedFlag extends AbstractModule {
246245 ) ;
247246 await this . core . rebuilder . $fetchLocal ( makeLocalChunkBeforeSync , ! makeLocalFilesBeforeSync ) ;
248247 await this . cleanupFetchAllFlag ( ) ;
249- this . _log ( "Fetch everything operation completed. Vault files will be gradually synced." , LOG_LEVEL_NOTICE ) ;
248+ this . _log ( $msg ( "RedFlag.Log.FetchEverythingCompleted" ) , LOG_LEVEL_NOTICE ) ;
250249 return true ;
251250 } ) ;
252251 }
@@ -270,7 +269,7 @@ export class ModuleRedFlag extends AbstractModule {
270269 }
271270 if (
272271 ( await this . core . confirm . askYesNoDialog (
273- "Do you want to resume file and database processing, and restart obsidian now?" ,
272+ $msg ( "RedFlag.ResumeProcessingPrompt" ) ,
274273 { defaultOption : "Yes" , timeout : 15 }
275274 ) ) != "yes"
276275 ) {
0 commit comments