feat(AppUpdater): implement localized update dialog (#6742)

feat(AppUpdater): implement localized update dialog with new translations for multiple languages

Co-authored-by: beyondkmp <beyondkmkp@gmail.com>
This commit is contained in:
beyondkmp 2025-06-03 12:34:12 +08:00 committed by GitHub
parent be1dae7ef0
commit cc2810b117
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 76 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import { UpdateInfo } from 'builder-util-runtime'
import { app, BrowserWindow, dialog } from 'electron' import { app, BrowserWindow, dialog } from 'electron'
import logger from 'electron-log' import logger from 'electron-log'
import { AppUpdater as _AppUpdater, autoUpdater } from 'electron-updater' import { AppUpdater as _AppUpdater, autoUpdater } from 'electron-updater'
import { locales } from '@main/utils/locales'
import icon from '../../../build/icon.png?asset' import icon from '../../../build/icon.png?asset'
import { configManager } from './ConfigManager' import { configManager } from './ConfigManager'
@ -94,15 +95,22 @@ export default class AppUpdater {
if (!this.releaseInfo) { if (!this.releaseInfo) {
return return
} }
const locale = locales[configManager.getLanguage()]
const { update: updateLocale } = locale.translation
let detail = this.formatReleaseNotes(this.releaseInfo.releaseNotes)
if (detail === '') {
detail = updateLocale.noReleaseNotes
}
dialog dialog
.showMessageBox({ .showMessageBox({
type: 'info', type: 'info',
title: '安装更新', title: updateLocale.title,
icon, icon,
message: `新版本 ${this.releaseInfo.version} 已准备就绪`, message: updateLocale.message.replace('{{version}}', this.releaseInfo.version),
detail: this.formatReleaseNotes(this.releaseInfo.releaseNotes), detail,
buttons: ['稍后安装', '立即安装'], buttons: [updateLocale.later, updateLocale.install],
defaultId: 1, defaultId: 1,
cancelId: 0 cancelId: 0
}) })
@ -118,7 +126,7 @@ export default class AppUpdater {
private formatReleaseNotes(releaseNotes: string | ReleaseNoteInfo[] | null | undefined): string { private formatReleaseNotes(releaseNotes: string | ReleaseNoteInfo[] | null | undefined): string {
if (!releaseNotes) { if (!releaseNotes) {
return '暂无更新说明' return ''
} }
if (typeof releaseNotes === 'string') { if (typeof releaseNotes === 'string') {

View File

@ -1844,6 +1844,13 @@
"show_window": "Show Window", "show_window": "Show Window",
"visualization": "Visualization" "visualization": "Visualization"
}, },
"update": {
"title": "Update",
"message": "New version {{version}} is ready, do you want to install it now?",
"later": "Later",
"install": "Install",
"noReleaseNotes": "No release notes"
},
"selection": { "selection": {
"name": "Selection Assistant", "name": "Selection Assistant",
"action": { "action": {

View File

@ -1844,6 +1844,13 @@
"show_window": "ウィンドウを表示", "show_window": "ウィンドウを表示",
"visualization": "可視化" "visualization": "可視化"
}, },
"update": {
"title": "更新",
"message": "新バージョン {{version}} が利用可能です。今すぐインストールしますか?",
"later": "後で",
"install": "今すぐインストール",
"noReleaseNotes": "暫無更新日誌"
},
"selection": { "selection": {
"name": "テキスト選択ツール", "name": "テキスト選択ツール",
"action": { "action": {

View File

@ -1844,6 +1844,13 @@
"show_window": "Показать окно", "show_window": "Показать окно",
"visualization": "Визуализация" "visualization": "Визуализация"
}, },
"update": {
"title": "Обновление",
"message": "Новая версия {{version}} готова, установить сейчас?",
"later": "Позже",
"install": "Установить",
"noReleaseNotes": "Нет заметок об обновлении"
},
"selection": { "selection": {
"name": "Помощник выбора", "name": "Помощник выбора",
"action": { "action": {

View File

@ -1844,6 +1844,13 @@
"show_window": "显示窗口", "show_window": "显示窗口",
"visualization": "可视化" "visualization": "可视化"
}, },
"update": {
"title": "更新提示",
"message": "发现新版本 {{version}},是否立即安装?",
"later": "稍后",
"install": "立即安装",
"noReleaseNotes": "暂无更新日志"
},
"selection": { "selection": {
"name": "划词助手", "name": "划词助手",
"action": { "action": {

View File

@ -1844,6 +1844,13 @@
"show_window": "顯示視窗", "show_window": "顯示視窗",
"visualization": "視覺化" "visualization": "視覺化"
}, },
"update": {
"title": "更新提示",
"message": "新版本 {{version}} 已準備就緒,是否立即安裝?",
"later": "稍後",
"install": "立即安裝",
"noReleaseNotes": "暫無更新日誌"
},
"selection": { "selection": {
"name": "劃詞助手", "name": "劃詞助手",
"action": { "action": {

View File

@ -1658,6 +1658,13 @@
"quit": "Έξοδος", "quit": "Έξοδος",
"show_window": "Εμφάνιση Παραθύρου", "show_window": "Εμφάνιση Παραθύρου",
"visualization": "προβολή" "visualization": "προβολή"
},
"update": {
"title": "Ενημέρωση",
"message": "Νέα έκδοση {{version}} είναι έτοιμη, θέλετε να την εγκαταστήσετε τώρα;",
"later": "Μετά",
"install": "Εγκατάσταση",
"noReleaseNotes": "Χωρίς σημειώσεις"
} }
} }
} }

View File

@ -1657,6 +1657,13 @@
"quit": "Salir", "quit": "Salir",
"show_window": "Mostrar Ventana", "show_window": "Mostrar Ventana",
"visualization": "Visualización" "visualization": "Visualización"
},
"update": {
"title": "Actualización",
"message": "Nueva versión {{version}} disponible, ¿desea instalarla ahora?",
"later": "Más tarde",
"install": "Instalar",
"noReleaseNotes": "Sin notas de la versión"
} }
} }
} }

View File

@ -1658,6 +1658,13 @@
"quit": "Quitter", "quit": "Quitter",
"show_window": "Afficher la fenêtre", "show_window": "Afficher la fenêtre",
"visualization": "Visualisation" "visualization": "Visualisation"
},
"update": {
"title": "Mise à jour",
"message": "Nouvelle version {{version}} disponible, voulez-vous l'installer maintenant ?",
"later": "Plus tard",
"install": "Installer",
"noReleaseNotes": "Aucune note de version"
} }
} }
} }

View File

@ -1660,6 +1660,13 @@
"quit": "Sair", "quit": "Sair",
"show_window": "Exibir Janela", "show_window": "Exibir Janela",
"visualization": "Visualização" "visualization": "Visualização"
},
"update": {
"title": "Atualização",
"message": "Nova versão {{version}} disponível, deseja instalar agora?",
"later": "Mais tarde",
"install": "Instalar",
"noReleaseNotes": "Sem notas de versão"
} }
} }
} }