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

View File

@ -1844,6 +1844,13 @@
"show_window": "Show Window",
"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": {
"name": "Selection Assistant",
"action": {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1657,6 +1657,13 @@
"quit": "Salir",
"show_window": "Mostrar Ventana",
"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",
"show_window": "Afficher la fenêtre",
"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",
"show_window": "Exibir Janela",
"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"
}
}
}