From c5a7352b298d5dee6ba826a6b9df1eb32f3a924e Mon Sep 17 00:00:00 2001 From: Janlhin <72262030+Janlhin@users.noreply.github.com> Date: Wed, 4 Nov 2026 01:56:37 +0800 Subject: [PATCH] i18n: extract Devices and the root App Extract the user-facing English strings of the Devices view and the root App.svelte into the catalog (en / zh-Hans / zh-Hant), one key per sentence, grouped per component (devices.* / app.*). en.json stays the source of truth; both Chinese scripts are aligned, no orphan keys. No lib/ behavior changes. - src/lib/i18n.test.js alignment gate green (0 missing / 0 extra / no empty) - npm test 336/336, vite build clean (removed now-dead .boot-hint code rule) --- cmd/opensave-app/frontend/src/App.svelte | 45 +++++------- cmd/opensave-app/frontend/src/locales/en.json | 63 +++++++++++++++- .../frontend/src/locales/zh-Hans.json | 63 +++++++++++++++- .../frontend/src/locales/zh-Hant.json | 63 +++++++++++++++- .../frontend/src/views/Devices.svelte | 73 +++++++++---------- 5 files changed, 241 insertions(+), 66 deletions(-) diff --git a/cmd/opensave-app/frontend/src/App.svelte b/cmd/opensave-app/frontend/src/App.svelte index cce5ee7d..f235ff9d 100644 --- a/cmd/opensave-app/frontend/src/App.svelte +++ b/cmd/opensave-app/frontend/src/App.svelte @@ -6,7 +6,7 @@ import { startController, controllerOn, padUsed, pageStep } from './lib/controller.js'; import { startFocusRing } from './lib/focusring.js'; import { appearance } from './lib/appearance.js'; - import { locale, resolveLocale } from './lib/i18n.js'; + import { locale, resolveLocale, t } from './lib/i18n.js'; import { paletteOpen } from './lib/shortcuts.js'; import { newlyEmptied } from './lib/emptied.js'; import { demandAttention } from './lib/notify.js'; @@ -111,13 +111,13 @@ const { now, fresh } = newlyEmptied(emptiedBefore, all); emptiedBefore = now; for (const g of fresh) { - toast(`Every save file of ${g.name} was deleted here. Your other devices keep theirs until you choose.`, 'warning', { + toast($t('app.emptiedBody', { name: g.name }), 'warning', { ttl: 15000, - action: { label: 'Choose', run: () => navigate('game', { gameId: g.id }) } + action: { label: $t('app.choose'), run: () => navigate('game', { gameId: g.id }) } }); demandAttention('emptied', { title: g.name, - body: 'Every save file was deleted here. Your other devices keep theirs until you choose.', + body: $t('app.emptiedBody', { name: g.name }), game: g }); } @@ -198,34 +198,34 @@
{#if $appUpdate.state === 'downloading'} - Updating OpenSave — downloading {$appUpdate.percentage ?? 0}%… + {$t('app.updatingDownloading', { n: $appUpdate.percentage ?? 0 })} {:else if $appUpdate.state === 'installing'} - Installing update… + {$t('app.installingUpdate')} {:else} - Restarting with the new version… + {$t('app.restartingVersion')} {/if} - The app restarts itself when done — your games keep syncing. + {$t('app.restartsItself')}
{:else if update}
- OpenSave {update.latest} is available — you're on {update.current}. + {$t('app.updateAvailable', { latest: update.latest, current: update.current })}
{#if update.notes} {/if} {#if update.assetUrl} {:else if update.flatpak} - + {:else} - + {/if} - +
{#if showNotes && update.notes} @@ -233,10 +233,10 @@ {/if} {:else if updatedTo}
- OpenSave was updated to v{updatedTo}. + {$t('app.updatedTo', { version: updatedTo })}
- - + +
{/if} @@ -252,13 +252,13 @@ {#if bootError}
-

OpenSave failed to start

+

{$t('app.failedToStart')}

{bootError}

- Details are saved to .opensave\opensave.log in your user folder. + {$t('app.detailsSaved')}

{:else if ready} @@ -361,11 +361,6 @@ color: var(--text-dim) !important; font-size: 0.8rem; } - .boot-hint code { - background: var(--bg-raised); - padding: 1px 5px; - border-radius: 5px; - } .update-banner { display: flex; align-items: center; diff --git a/cmd/opensave-app/frontend/src/locales/en.json b/cmd/opensave-app/frontend/src/locales/en.json index 8f5cd4ae..29586171 100644 --- a/cmd/opensave-app/frontend/src/locales/en.json +++ b/cmd/opensave-app/frontend/src/locales/en.json @@ -637,5 +637,66 @@ "game.config.deviceSettingsHint": "The game database lists these as this game's settings, not its save, so each device keeps its own (graphics, resolution). They are still in every snapshot.", "notifications.clearAll": "Clear all", "notifications.clearAllTitle": "Take these out of the bell. Activity still has them.", - "palette.renameGame": "Rename {game}" + "palette.renameGame": "Rename {game}", + "devices.title": "Devices", + "devices.paired": "Paired devices", + "devices.noPaired": "No paired devices", + "devices.noPairedHint": "Pair a device below — on your Wi-Fi it appears automatically, or connect over the internet with a room code.", + "devices.statusOnline": "Online", + "devices.statusOffline": "Offline", + "devices.internetRelay": "internet relay", + "devices.lastSynced": "last synced {time}", + "devices.never": "never", + "devices.opensaveVersion": "OpenSave {version}", + "devices.fixThis": "Fix this", + "devices.trustTooltip": "For your own devices: games it syncs go in the folder it names, even one this device doesn't recognise as a save, instead of waiting on Home for you.", + "devices.trustLabel": "Trust it to choose folders", + "devices.updateFromThis": "Update from this device", + "devices.unpair": "Unpair", + "devices.addDevice": "Add a device", + "devices.onThisNetwork": "On this network", + "devices.overInternet": "Over the internet", + "devices.lanIntro": "Devices running OpenSave on the same Wi-Fi/Ethernet discover each other automatically. No setup needed.", + "devices.foundOnNetwork": "Found on your network", + "devices.noLanFound": "No unpaired devices found on the local network. Make sure OpenSave is running on the other device.", + "devices.pair": "Pair", + "devices.addByIp": "Add by IP address", + "devices.sendPairing": "Send pairing request", + "devices.pairingSentTo": "Pairing request sent to {name}", + "devices.pairingSent": "Pairing request sent", + "devices.unpairConfirmTitle": "Unpair device?", + "devices.unpairConfirmBody": "Unpair \"{name}\"? Their games stay on both devices; syncing between you stops.", + "devices.unpairConfirmText": "Unpair", + "devices.unpaired": "Unpaired {name}", + "devices.trustConfirmTitle": "Trust \"{name}\" to choose folders?", + "devices.trustConfirmBody": "Only do this for a device that is yours. When \"{name}\" syncs a game this device doesn't recognise, its saves go in the folder \"{name}\" names, instead of waiting on Home for you to choose one.", + "devices.trustConfirmText": "Trust it", + "devices.canChooseFolders": "{name} can choose folders here", + "devices.noLongerChooses": "{name} no longer chooses folders here", + "devices.repairConfirmTitle": "Unpair, so you can pair again?", + "devices.repairConfirmBody": "Unpair \"{name}\", then pair the two devices again so they exchange an encryption key. Their games and saves stay where they are. Nothing syncs between these two devices until you pair them again.", + "devices.repairConfirmText": "Unpair now", + "devices.repairedToast": "Unpaired {name} — pair the two devices again to encrypt what you sync", + "devices.updateConfirmTitle": "Update OpenSave?", + "devices.updateConfirmBody": "{name} is running a newer OpenSave build ({version}). Download it from {name} and update this device? OpenSave restarts itself when done.", + "devices.updateConfirmText": "Update & restart", + "app.updatingDownloading": "Updating OpenSave — downloading {n}%…", + "app.installingUpdate": "Installing update…", + "app.restartingVersion": "Restarting with the new version…", + "app.restartsItself": "The app restarts itself when done — your games keep syncing.", + "app.updateAvailable": "OpenSave {latest} is available — you're on {current}.", + "app.hideNotes": "Hide notes", + "app.whatsNew": "What's new", + "app.starting": "Starting…", + "app.installRestart": "Install & restart", + "app.getFlatpak": "Get .flatpak", + "app.download": "Download", + "app.updatedTo": "OpenSave was updated to v{version}.", + "app.failedToStart": "OpenSave failed to start", + "app.retrying": "Retrying…", + "app.retry": "Retry", + "app.detailsSaved": "Details are saved to .opensave\\opensave.log in your user folder.", + "app.startingOpenSave": "Starting OpenSave…", + "app.emptiedBody": "Every save file of {name} was deleted here. Your other devices keep theirs until you choose.", + "app.choose": "Choose" } diff --git a/cmd/opensave-app/frontend/src/locales/zh-Hans.json b/cmd/opensave-app/frontend/src/locales/zh-Hans.json index 0f9c7bc8..dd8033c0 100644 --- a/cmd/opensave-app/frontend/src/locales/zh-Hans.json +++ b/cmd/opensave-app/frontend/src/locales/zh-Hans.json @@ -550,5 +550,66 @@ "game.config.deviceSettingsHint": "游戏数据库将这些文件列为该游戏的设置而非存档,因此每台设备保留各自的设置(画质、分辨率)。它们仍包含在每个快照中。", "notifications.clearAll": "清除全部", "notifications.clearAllTitle": "将这些从铃铛移除,活动页仍保留", - "palette.renameGame": "重命名 {game}" + "palette.renameGame": "重命名 {game}", + "devices.title": "设备", + "devices.paired": "已配对的设备", + "devices.noPaired": "没有已配对的设备", + "devices.noPairedHint": "在下方配对设备——它会自动出现在你的 Wi-Fi 上,或者通过互联网用房间码连接。", + "devices.statusOnline": "在线", + "devices.statusOffline": "离线", + "devices.internetRelay": "互联网中继", + "devices.lastSynced": "上次同步 {time}", + "devices.never": "从未", + "devices.opensaveVersion": "OpenSave {version}", + "devices.fixThis": "修复", + "devices.trustTooltip": "仅适用于你自己的设备:它同步的游戏会存入它指定的文件夹,即便是本设备未识别为存档的文件夹,而不是等待你在主页选择。", + "devices.trustLabel": "信任它来选择文件夹", + "devices.updateFromThis": "从此设备更新", + "devices.unpair": "取消配对", + "devices.addDevice": "添加设备", + "devices.onThisNetwork": "本网络", + "devices.overInternet": "通过互联网", + "devices.lanIntro": "在同一 Wi-Fi/以太网 上运行 OpenSave 的设备会自动互相发现,无需设置。", + "devices.foundOnNetwork": "在你的网络上找到", + "devices.noLanFound": "在本地网络上未找到未配对的设备。请确认另一台设备正在运行 OpenSave。", + "devices.pair": "配对", + "devices.addByIp": "通过 IP 地址添加", + "devices.sendPairing": "发送配对请求", + "devices.pairingSentTo": "已向 {name} 发送配对请求", + "devices.pairingSent": "配对请求已发送", + "devices.unpairConfirmTitle": "取消配对设备?", + "devices.unpairConfirmBody": "取消配对“{name}”?它的游戏会保留在两端设备上;你们之间的同步将停止。", + "devices.unpairConfirmText": "取消配对", + "devices.unpaired": "已取消配对 {name}", + "devices.trustConfirmTitle": "信任“{name}”来选择文件夹?", + "devices.trustConfirmBody": "只对你自己的设备这样做。当“{name}”同步本设备未识别为存档的游戏时,它的存档会放入“{name}”指定的文件夹,而不是等待你在主页选择。", + "devices.trustConfirmText": "信任它", + "devices.canChooseFolders": "{name} 可在此选择文件夹", + "devices.noLongerChooses": "{name} 不再在此选择文件夹", + "devices.repairConfirmTitle": "取消配对,以便重新配对?", + "devices.repairConfirmBody": "取消配对“{name}”,然后再次配对这两台设备,以便它们交换加密密钥。它的游戏与存档保留在原处。在你重新配对之前,这两台设备之间不会同步任何内容。", + "devices.repairConfirmText": "现在取消配对", + "devices.repairedToast": "已取消配对 {name}——再次配对这两台设备以加密你同步的内容", + "devices.updateConfirmTitle": "更新 OpenSave?", + "devices.updateConfirmBody": "{name} 正在运行较新的 OpenSave 构建({version})。从 {name} 下载并更新此设备?完成后 OpenSave 会自动重启。", + "devices.updateConfirmText": "更新并重启", + "app.updatingDownloading": "正在更新 OpenSave——下载 {n}%…", + "app.installingUpdate": "正在安装更新…", + "app.restartingVersion": "正在以新版本重启…", + "app.restartsItself": "完成后应用会自动重启——你的游戏会继续同步。", + "app.updateAvailable": "OpenSave {latest} 已可用——你当前为 {current}。", + "app.hideNotes": "隐藏说明", + "app.whatsNew": "新内容", + "app.starting": "正在启动…", + "app.installRestart": "安装并重启", + "app.getFlatpak": "获取 .flatpak", + "app.download": "下载", + "app.updatedTo": "OpenSave 已更新至 v{version}。", + "app.failedToStart": "OpenSave 启动失败", + "app.retrying": "正在重试…", + "app.retry": "重试", + "app.detailsSaved": "Details are saved to .opensave\\opensave.log in your user folder.", + "app.startingOpenSave": "正在启动 OpenSave…", + "app.emptiedBody": "{name} 的所有存档文件在此处都被删除了。你的其他设备会保留它们,直到你做出选择。", + "app.choose": "选择" } diff --git a/cmd/opensave-app/frontend/src/locales/zh-Hant.json b/cmd/opensave-app/frontend/src/locales/zh-Hant.json index 60a64436..f560fa59 100644 --- a/cmd/opensave-app/frontend/src/locales/zh-Hant.json +++ b/cmd/opensave-app/frontend/src/locales/zh-Hant.json @@ -550,5 +550,66 @@ "game.config.deviceSettingsHint": "遊戲資料庫將這些檔案列為該遊戲的設定而非存檔,因此每臺裝置保留各自的設定(畫質、解析度)。它們仍包含在每個快照中。", "notifications.clearAll": "清除全部", "notifications.clearAllTitle": "將這些從鈴鐺移除,活動頁仍保留", - "palette.renameGame": "重新命名 {game}" + "palette.renameGame": "重新命名 {game}", + "devices.title": "裝置", + "devices.paired": "已配對的裝置", + "devices.noPaired": "沒有已配對的裝置", + "devices.noPairedHint": "在下方配對裝置——它會自動出現在你的 Wi-Fi 上,或者透過網際網路使用房間碼連線。", + "devices.statusOnline": "線上", + "devices.statusOffline": "離線", + "devices.internetRelay": "網際網路中繼", + "devices.lastSynced": "上次同步 {time}", + "devices.never": "從未", + "devices.opensaveVersion": "OpenSave {version}", + "devices.fixThis": "修復", + "devices.trustTooltip": "僅適用於你自己的裝置:它同步的遊戲會存入它指定的資料夾,即便是本裝置未識別為存檔的資料夾,而不是等待你在主頁選擇。", + "devices.trustLabel": "信任它來選擇資料夾", + "devices.updateFromThis": "從此裝置更新", + "devices.unpair": "取消配對", + "devices.addDevice": "新增裝置", + "devices.onThisNetwork": "本網路", + "devices.overInternet": "透過網際網路", + "devices.lanIntro": "在同一 Wi-Fi/乙太網路上執行 OpenSave 的裝置會自動互相發現,無需設定。", + "devices.foundOnNetwork": "在你的網路上找到", + "devices.noLanFound": "在本地網路上未找到未配對的裝置。請確認另一台裝置正在執行 OpenSave。", + "devices.pair": "配對", + "devices.addByIp": "透過 IP 位址新增", + "devices.sendPairing": "傳送配對請求", + "devices.pairingSentTo": "已向 {name} 傳送配對請求", + "devices.pairingSent": "配對請求已傳送", + "devices.unpairConfirmTitle": "取消配對裝置?", + "devices.unpairConfirmBody": "取消配對“{name}”?它的遊戲會保留在兩端裝置上;你們之間的同步將停止。", + "devices.unpairConfirmText": "取消配對", + "devices.unpaired": "已取消配對 {name}", + "devices.trustConfirmTitle": "信任“{name}”來選擇資料夾?", + "devices.trustConfirmBody": "只對你自己的裝置這樣做。當“{name}”同步本裝置未識別為存檔的遊戲時,它的存檔會放入“{name}”指定的資料夾,而不是等待你在主頁選擇。", + "devices.trustConfirmText": "信任它", + "devices.canChooseFolders": "{name} 可在此選擇資料夾", + "devices.noLongerChooses": "{name} 不再在此選擇資料夾", + "devices.repairConfirmTitle": "取消配對,以便重新配對?", + "devices.repairConfirmBody": "取消配對“{name}”,然後再次配對這兩台裝置,以便它們交換加密金鑰。它的遊戲與存檔保留在原處。在你重新配對之前,這兩台裝置之間不會同步任何內容。", + "devices.repairConfirmText": "現在取消配對", + "devices.repairedToast": "已取消配對 {name}——再次配對這兩台裝置以加密你同步的內容", + "devices.updateConfirmTitle": "更新 OpenSave?", + "devices.updateConfirmBody": "{name} 正在執行較新的 OpenSave 建置({version})。從 {name} 下載並更新此裝置?完成後 OpenSave 會自動重新啟動。", + "devices.updateConfirmText": "更新並重新啟動", + "app.updatingDownloading": "正在更新 OpenSave——下載 {n}%…", + "app.installingUpdate": "正在安裝更新…", + "app.restartingVersion": "正在以新版本重新啟動…", + "app.restartsItself": "完成後應用程式會自動重新啟動——你的遊戲會繼續同步。", + "app.updateAvailable": "OpenSave {latest} 已可用——你目前為 {current}。", + "app.hideNotes": "隱藏說明", + "app.whatsNew": "新內容", + "app.starting": "正在啟動…", + "app.installRestart": "安裝並重新啟動", + "app.getFlatpak": "取得 .flatpak", + "app.download": "下載", + "app.updatedTo": "OpenSave 已更新至 v{version}。", + "app.failedToStart": "OpenSave 啟動失敗", + "app.retrying": "正在重試…", + "app.retry": "重試", + "app.detailsSaved": "Details are saved to .opensave\\opensave.log in your user folder.", + "app.startingOpenSave": "正在啟動 OpenSave…", + "app.emptiedBody": "{name} 的所有存檔檔案在此處都被刪除了。你的其他裝置會保留它們,直到你做出選擇。", + "app.choose": "選擇" } diff --git a/cmd/opensave-app/frontend/src/views/Devices.svelte b/cmd/opensave-app/frontend/src/views/Devices.svelte index 28aa2405..18e1fe73 100644 --- a/cmd/opensave-app/frontend/src/views/Devices.svelte +++ b/cmd/opensave-app/frontend/src/views/Devices.svelte @@ -1,5 +1,6 @@
-

Devices

+

{$t('devices.title')}

-

Paired devices

+

{$t('devices.paired')}

{#if pairedList.length === 0}
-

No paired devices

-

Pair a device below — on your Wi-Fi it appears automatically, or connect over the internet with a room code.

+

{$t('devices.noPaired')}

+

{$t('devices.noPairedHint')}

{:else}
@@ -121,12 +118,12 @@
{peer.name} - {peer.status} + {peer.status === 'online' ? $t('devices.statusOnline') : peer.status === 'offline' ? $t('devices.statusOffline') : peer.status}
- {peer.address === 'relay' ? 'internet relay' : `${peer.address}:${peer.port}`} - · last synced {fmtTime(peer.lastSynced)} + {peer.address === 'relay' ? $t('devices.internetRelay') : `${peer.address}:${peer.port}`} + · {$t('devices.lastSynced', { time: fmtTime(peer.lastSynced) })} {#if peer.appVersion}· OpenSave {peer.appVersion}{/if}