From 63562240c46a85f8e117ce1e7a9762259f5dc1e7 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Sun, 31 Aug 2025 21:54:54 +0800 Subject: [PATCH] feat(localization): enhance English and Chinese translations for update notifications and support modal --- locales/en.json | 59 ++++++++++++++++++- locales/zh-CN.json | 59 ++++++++++++++++++- static/js/components/Header.js | 4 +- static/js/managers/UpdateService.js | 54 +++++++++-------- .../components/modals/support_modal.html | 30 +++++----- templates/components/modals/update_modal.html | 6 +- 6 files changed, 162 insertions(+), 50 deletions(-) diff --git a/locales/en.json b/locales/en.json index 78bfa0f2..c6235daa 100644 --- a/locales/en.json +++ b/locales/en.json @@ -14,7 +14,9 @@ }, "status": { "loading": "Loading...", - "unknown": "Unknown" + "unknown": "Unknown", + "date": "Date", + "version": "Version" }, "language": { "select": "Select Language", @@ -696,6 +698,8 @@ }, "update": { "title": "Check for Updates", + "updateAvailable": "Update Available", + "noChangelogAvailable": "No detailed changelog available. Check GitHub for more information.", "currentVersion": "Current Version", "newVersion": "New Version", "commit": "Commit", @@ -705,7 +709,27 @@ "changelog": "Changelog", "checkingUpdates": "Checking for updates...", "checkingMessage": "Please wait while we check for the latest version.", - "showNotifications": "Show update notifications" + "showNotifications": "Show update notifications", + "updateProgress": { + "preparing": "Preparing update...", + "installing": "Installing update...", + "completed": "Update completed successfully!", + "failed": "Update failed: {error}" + }, + "status": { + "updating": "Updating...", + "updated": "Updated!", + "updateFailed": "Update Failed" + }, + "completion": { + "successMessage": "Successfully updated to {version}!", + "restartMessage": "Please restart ComfyUI or LoRA Manager to apply update.", + "reloadMessage": "Make sure to reload your browser for both LoRA Manager and ComfyUI." + }, + "nightly": { + "warning": "Warning: Nightly builds may contain experimental features and could be unstable.", + "enable": "Enable Nightly Updates" + } }, "support": { "title": "Support the Project", @@ -713,7 +737,27 @@ "feedback": { "title": "Provide Feedback", "description": "Your feedback helps shape future updates! Share your thoughts:" - } + }, + "links": { + "submitGithubIssue": "Submit GitHub Issue", + "joinDiscord": "Join Discord", + "youtubeChannel": "YouTube Channel", + "civitaiProfile": "Civitai Profile", + "supportKofi": "Support on Ko-fi", + "supportPatreon": "Support on Patreon" + }, + "sections": { + "followUpdates": "Follow for Updates", + "buyMeCoffee": "Buy me a coffee", + "coffeeDescription": "If you'd like to support my work directly:", + "becomePatron": "Become a Patron", + "patronDescription": "Support ongoing development with monthly contributions:", + "wechatSupport": "WeChat Support", + "wechatDescription": "For users in China, you can support via WeChat:", + "showWechatQR": "Show WeChat QR Code", + "hideWechatQR": "Hide WeChat QR Code" + }, + "footer": "Thank you for using LoRA Manager! ❤️" }, "toast": { "general": { @@ -924,5 +968,14 @@ "exampleImagesDownloadSuccess": "Successfully downloaded example images!", "exampleImagesDownloadFailed": "Failed to download example images: {message}" } + }, + "banners": { + "versionMismatch": { + "title": "Application Update Detected", + "content": "Your browser is running an outdated version of LoRA Manager ({storedVersion}). The server has been updated to version {currentVersion}. Please refresh to ensure proper functionality.", + "refreshNow": "Refresh Now", + "refreshingIn": "Refreshing in", + "seconds": "seconds" + } } } diff --git a/locales/zh-CN.json b/locales/zh-CN.json index be8d4630..402c98e3 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -14,7 +14,9 @@ }, "status": { "loading": "加载中...", - "unknown": "未知" + "unknown": "未知", + "date": "日期", + "version": "版本" }, "language": { "select": "选择语言", @@ -697,6 +699,8 @@ "update": { "title": "检查更新", "currentVersion": "当前版本", + "updateAvailable": "更新可用", + "noChangelogAvailable": "没有详细的更新日志可用。请查看 GitHub 以获取更多信息。", "newVersion": "新版本", "commit": "提交", "viewOnGitHub": "在 GitHub 查看", @@ -705,7 +709,27 @@ "changelog": "更新日志", "checkingUpdates": "正在检查更新...", "checkingMessage": "请稍候,正在检查最新版本。", - "showNotifications": "显示更新通知" + "showNotifications": "显示更新通知", + "updateProgress": { + "preparing": "正在准备更新...", + "installing": "正在安装更新...", + "completed": "更新已成功完成!", + "failed": "更新失败:{error}" + }, + "status": { + "updating": "正在更新...", + "updated": "已更新!", + "updateFailed": "更新失败" + }, + "completion": { + "successMessage": "已成功更新到 {version}!", + "restartMessage": "请重启 ComfyUI 或 LoRA 管理器以应用更新。", + "reloadMessage": "请确保刷新浏览器以加载最新的 LoRA 管理器和 ComfyUI。" + }, + "nightly": { + "warning": "警告:Nightly 版本可能包含实验性功能,可能不稳定。", + "enable": "启用 Nightly 更新" + } }, "support": { "title": "支持项目", @@ -713,7 +737,27 @@ "feedback": { "title": "反馈建议", "description": "你的反馈有助于未来更新!欢迎分享你的想法:" - } + }, + "links": { + "submitGithubIssue": "提交 GitHub 问题", + "joinDiscord": "加入 Discord", + "youtubeChannel": "YouTube 频道", + "civitaiProfile": "Civitai 个人资料", + "supportKofi": "支持 Ko-fi", + "supportPatreon": "支持 Patreon" + }, + "sections": { + "followUpdates": "关注更新", + "buyMeCoffee": "请我喝杯咖啡", + "coffeeDescription": "如果你想直接支持我的工作:", + "becomePatron": "成为赞助人", + "patronDescription": "通过每月捐款支持持续开发:", + "wechatSupport": "微信支持", + "wechatDescription": "对于中国用户,你可以通过微信支持:", + "showWechatQR": "显示微信二维码", + "hideWechatQR": "隐藏微信二维码" + }, + "footer": "感谢使用 LoRA 管理器!❤️" }, "toast": { "general": { @@ -924,5 +968,14 @@ "exampleImagesDownloadSuccess": "示例图片下载成功!", "exampleImagesDownloadFailed": "示例图片下载失败:{message}" } + }, + "banners": { + "versionMismatch": { + "title": "检测到应用更新", + "content": "你的浏览器正在运行过时的 LoRA 管理器版本({storedVersion})。服务器已更新到版本 {currentVersion}。请刷新以确保正常使用。", + "refreshNow": "立即刷新", + "refreshingIn": "将在", + "seconds": "秒后刷新" + } } } diff --git a/static/js/components/Header.js b/static/js/components/Header.js index ab0e940d..49be670f 100644 --- a/static/js/components/Header.js +++ b/static/js/components/Header.js @@ -52,13 +52,13 @@ export class HeaderManager { const currentTheme = getStorageItem('theme') || 'auto'; themeToggle.classList.add(`theme-${currentTheme}`); - // 使用i18nHelpers更新themeToggle的title + // Use i18nHelpers to update themeToggle's title this.updateThemeTooltip(themeToggle, currentTheme); themeToggle.addEventListener('click', async () => { if (typeof toggleTheme === 'function') { const newTheme = toggleTheme(); - // 使用i18nHelpers更新themeToggle的title + // Use i18nHelpers to update themeToggle's title this.updateThemeTooltip(themeToggle, newTheme); } }); diff --git a/static/js/managers/UpdateService.js b/static/js/managers/UpdateService.js index 17723acf..5beb0f94 100644 --- a/static/js/managers/UpdateService.js +++ b/static/js/managers/UpdateService.js @@ -8,6 +8,7 @@ import { resetDismissedBanner } from '../utils/storageHelpers.js'; import { bannerService } from './BannerService.js'; +import { translate } from '../utils/i18nHelpers.js'; export class UpdateService { constructor() { @@ -165,8 +166,8 @@ export class UpdateService { if (updateToggle) { updateToggle.title = this.updateNotificationsEnabled && this.updateAvailable - ? "Update Available" - : "Check Updates"; + ? translate('update.updateAvailable') + : translate('update.title'); } // Force updating badges visibility based on current state @@ -185,7 +186,9 @@ export class UpdateService { // Update title based on update availability const headerTitle = modal.querySelector('.update-header h2'); if (headerTitle) { - headerTitle.textContent = this.updateAvailable ? "Update Available" : "Check for Updates"; + headerTitle.textContent = this.updateAvailable ? + translate('update.updateAvailable') : + translate('update.title'); } // Always update version information, even if updateInfo is null @@ -209,9 +212,9 @@ export class UpdateService { const gitInfoEl = modal.querySelector('.git-info'); if (gitInfoEl && this.gitInfo) { if (this.gitInfo.short_hash !== 'unknown') { - let gitText = `Commit: ${this.gitInfo.short_hash}`; + let gitText = `${translate('update.commit')}: ${this.gitInfo.short_hash}`; if (this.gitInfo.commit_date !== 'unknown') { - gitText += ` - Date: ${this.gitInfo.commit_date}`; + gitText += ` - ${translate('common.status.date', {}, 'Date')}: ${this.gitInfo.commit_date}`; } gitInfoEl.textContent = gitText; gitInfoEl.style.display = 'block'; @@ -231,7 +234,7 @@ export class UpdateService { changelogItem.className = 'changelog-item'; const versionHeader = document.createElement('h4'); - versionHeader.textContent = `Version ${this.latestVersion}`; + versionHeader.textContent = `${translate('common.status.version', {}, 'Version')} ${this.latestVersion}`; changelogItem.appendChild(versionHeader); // Create changelog list @@ -247,7 +250,7 @@ export class UpdateService { } else { // If no changelog items available const listItem = document.createElement('li'); - listItem.textContent = "No detailed changelog available. Check GitHub for more information."; + listItem.textContent = translate('update.noChangelogAvailable', {}, 'No detailed changelog available. Check GitHub for more information.'); changelogList.appendChild(listItem); } @@ -271,11 +274,11 @@ export class UpdateService { try { this.isUpdating = true; - this.updateUpdateUI('updating', 'Updating...'); + this.updateUpdateUI('updating', translate('update.status.updating')); this.showUpdateProgress(true); // Update progress - this.updateProgress(10, 'Preparing update...'); + this.updateProgress(10, translate('update.updateProgress.preparing')); const response = await fetch('/api/perform-update', { method: 'POST', @@ -287,13 +290,13 @@ export class UpdateService { }) }); - this.updateProgress(50, 'Installing update...'); + this.updateProgress(50, translate('update.updateProgress.installing')); const data = await response.json(); if (data.success) { - this.updateProgress(100, 'Update completed successfully!'); - this.updateUpdateUI('success', 'Updated!'); + this.updateProgress(100, translate('update.updateProgress.completed')); + this.updateUpdateUI('success', translate('update.status.updated')); // Show success message and suggest restart setTimeout(() => { @@ -301,13 +304,13 @@ export class UpdateService { }, 1000); } else { - throw new Error(data.error || 'Update failed'); + throw new Error(data.error || translate('update.status.updateFailed')); } } catch (error) { console.error('Update failed:', error); - this.updateUpdateUI('error', 'Update Failed'); - this.updateProgress(0, `Update failed: ${error.message}`); + this.updateUpdateUI('error', translate('update.status.updateFailed')); + this.updateProgress(0, translate('update.updateProgress.failed', { error: error.message })); // Hide progress after error setTimeout(() => { @@ -369,11 +372,11 @@ export class UpdateService { progressText.innerHTML = `
- Successfully updated to ${newVersion}! + ${translate('update.completion.successMessage', { version: newVersion })}

- Please restart ComfyUI or LoRA Manager to apply update.
- Make sure to reload your browser for both LoRA Manager and ComfyUI. + ${translate('update.completion.restartMessage')}
+ ${translate('update.completion.reloadMessage')}
`; @@ -470,16 +473,19 @@ export class UpdateService { registerVersionMismatchBanner() { // Get stored and current version for display - const storedVersion = getStoredVersionInfo() || 'unknown'; - const currentVersion = this.currentVersionInfo || 'unknown'; + const storedVersion = getStoredVersionInfo() || translate('common.status.unknown'); + const currentVersion = this.currentVersionInfo || translate('common.status.unknown'); bannerService.registerBanner('version-mismatch', { id: 'version-mismatch', - title: 'Application Update Detected', - content: `Your browser is running an outdated version of LoRA Manager (${storedVersion}). The server has been updated to version ${currentVersion}. Please refresh to ensure proper functionality.`, + title: translate('banners.versionMismatch.title', {}, 'Application Update Detected'), + content: translate('banners.versionMismatch.content', { + storedVersion, + currentVersion + }, `Your browser is running an outdated version of LoRA Manager (${storedVersion}). The server has been updated to version ${currentVersion}. Please refresh to ensure proper functionality.`), actions: [ { - text: 'Refresh Now', + text: translate('banners.versionMismatch.refreshNow', {}, 'Refresh Now'), icon: 'fas fa-sync', action: 'hardRefresh', type: 'primary' @@ -492,7 +498,7 @@ export class UpdateService { // Add countdown element const countdownEl = document.createElement('div'); countdownEl.className = 'banner-countdown'; - countdownEl.innerHTML = `Refreshing in 15 seconds...`; + countdownEl.innerHTML = `${translate('banners.versionMismatch.refreshingIn', {}, 'Refreshing in')} 15 ${translate('banners.versionMismatch.seconds', {}, 'seconds')}...`; bannerElement.querySelector('.banner-content').appendChild(countdownEl); // Start countdown diff --git a/templates/components/modals/support_modal.html b/templates/components/modals/support_modal.html index 03dbc51a..71298544 100644 --- a/templates/components/modals/support_modal.html +++ b/templates/components/modals/support_modal.html @@ -15,21 +15,21 @@
-

Follow for Updates

+

{{ t('support.sections.followUpdates') }}

-

Buy me a coffee

-

If you'd like to support my work directly:

+

{{ t('support.sections.buyMeCoffee') }}

+

{{ t('support.sections.coffeeDescription') }}

- Support on Ko-fi + {{ t('support.links.supportKofi') }}
-

Become a Patron

-

Support ongoing development with monthly contributions:

+

{{ t('support.sections.becomePatron') }}

+

{{ t('support.sections.patronDescription') }}

- Support on Patreon + {{ t('support.links.supportPatreon') }}
-

WeChat Support

-

For users in China, you can support via WeChat:

+

{{ t('support.sections.wechatSupport') }}

+

{{ t('support.sections.wechatDescription') }}

@@ -84,7 +84,7 @@
diff --git a/templates/components/modals/update_modal.html b/templates/components/modals/update_modal.html index cbc4122f..91742df3 100644 --- a/templates/components/modals/update_modal.html +++ b/templates/components/modals/update_modal.html @@ -4,7 +4,7 @@
-

{{ t('update.title') }}

+

{{ t('update.title') }}

@@ -26,7 +26,7 @@
@@ -34,7 +34,7 @@