Skip to content

Build your personal knowledge base with Trilium Notes

standalone/options/backup: fix a missing translation string

Adorian Doranc4956782d304
diff --git a/apps/client/src/setup_restore.spec.tsx b/apps/client/src/setup_restore.spec.tsx
index d628a056b2..246a91d993 100644
--- a/apps/client/src/setup_restore.spec.tsx
+++ b/apps/client/src/setup_restore.spec.tsx
@@ -7,6 +7,8 @@ vi.mock("./services/i18n", () => ({
t: (key: string, values?: Record<string, unknown>) => [ key, ...Object.values(values ?? {}) ].join(" ")
}));
+import en from "./translations/en/translation.json";
+
const serverMock = vi.hoisted(() => ({
// The default serves what transitively imported modules ask for as they load (keyboard_actions
// fetches its shortcut list on import); the routing installed in beforeEach overrides it.
@@ -27,7 +29,7 @@ const uploadMock = vi.hoisted(() => ({
}));
vi.mock("./services/chunked_upload", () => uploadMock);
-import RestoreFromBackup from "./setup_restore";
+import RestoreFromBackup, { stageLabel } from "./setup_restore";
const BACKUPS = [
{ fileName: "backup-daily.db", filePath: "/data/backup/backup-daily.db", mtime: "2026-08-01T10:00:00Z", fileSize: 2048, encrypted: false },
@@ -674,3 +676,31 @@ describe("following the restore", () => {
expect(headline()).toBe("setup.restore-error-too-old");
});
});
+
+describe("what the restore calls the stage it is at", () => {
+ // Every stage either restore reports: the server's, and the browser-only one which is alone in
+ // reporting the two that end it.
+ const stages = [ "staging", "validating", "swapping", "migrating", "done", "failed" ];
+
+ it("has a sentence for every stage a restore can report", () => {
+ // t() is mocked to hand back the key, so what a label comes back as is the key it looked
+ // up: it has to be one the catalogue actually defines, or the user is shown the key itself.
+ for (const stage of stages) {
+ const label = stageLabel(stage);
+ if (!label) {
+ continue;
+ }
+
+ const [ namespace, key ] = label.split(".");
+ expect(namespace).toBe("setup");
+ expect(en.setup).toHaveProperty(key);
+ }
+ });
+
+ it("says what happens next once the restore is done, rather than naming a finished step", () => {
+ // The frame between the last step and the reload, and the one the user watches hardest.
+ expect(stageLabel("done")).toBe("setup.redirecting");
+ // Nothing is said about a failure here: the screen replacing this one says it properly.
+ expect(stageLabel("failed")).toBe("");
+ });
+});
diff --git a/apps/client/src/setup_restore.tsx b/apps/client/src/setup_restore.tsx
index b2d0533bab..706d52a3da 100644
--- a/apps/client/src/setup_restore.tsx
+++ b/apps/client/src/setup_restore.tsx
@@ -605,7 +605,7 @@ function RestoreProgress({ reported, onRestored, onFailed }: {
// the user three things they will never see happen.
return (
<div class="restore-current-step">
- <div class="restore-step-name">{t(`setup.restore-stage-${shownStage}`)}</div>
+ <div class="restore-step-name">{stageLabel(shownStage)}</div>
{/* Only where the step can say how far it has got. The ones that cannot show nothing,
rather than an empty bar that never moves. */}
@@ -620,3 +620,28 @@ function RestoreProgress({ reported, onRestored, onFailed }: {
</div>
);
}
+
+/**
+ * What to call the stage the restore says it is at.
+ *
+ * Spelled out rather than composed into a key. Built as `restore-stage-${stage}`, a stage nobody
+ * wrote a sentence for printed its own key at the user: `done` is reported by the browser-only
+ * restore in the moment between the last step and the reload, and that moment is the one the user
+ * is watching hardest.
+ *
+ * `done` is not a step at all but what follows the last one, so it says what is about to happen
+ * instead of naming something already finished. A failure says nothing here, because the screen it
+ * is about to be replaced by says it properly.
+ */
+export function stageLabel(stage: string): string {
+ switch (stage) {
+ case "validating": return t("setup.restore-stage-validating");
+ case "swapping": return t("setup.restore-stage-swapping");
+ case "migrating": return t("setup.restore-stage-migrating");
+ case "done": return t("setup.redirecting");
+ case "failed": return "";
+ // Staging both as itself and as the answer for a stage this does not know: whatever it is
+ // called, a restore that has not ended is one still working on the backup.
+ default: return t("setup.restore-stage-staging");
+ }
+}