From da7e026550d370c798ffac384c8de2e6060e3024 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 2 Dec 2024 15:08:33 -0800 Subject: [PATCH] Mark dialog strings for translation. Signed-off-by: Anders Kaseorg --- app/main/autoupdater.ts | 44 ++++++++++++------- app/main/index.ts | 10 +++-- app/main/linux-update-util.ts | 5 ++- app/renderer/js/components/webview.ts | 5 ++- app/renderer/js/main.ts | 17 ++++--- .../js/pages/preference/general-section.ts | 10 ++--- .../js/pages/preference/new-server-form.ts | 4 +- .../js/pages/preference/server-info-form.ts | 2 +- app/renderer/js/utils/domain-util.ts | 7 +-- public/translations/en.json | 34 +++++++++++++- 10 files changed, 92 insertions(+), 46 deletions(-) diff --git a/app/main/autoupdater.ts b/app/main/autoupdater.ts index 189b8807e..89687d197 100644 --- a/app/main/autoupdater.ts +++ b/app/main/autoupdater.ts @@ -10,6 +10,7 @@ import { } from "electron-updater"; import * as ConfigUtil from "../common/config-util.js"; +import * as t from "../common/translation-util.js"; import {linuxUpdateNotification} from "./linuxupdater.js"; // Required only in case of linux @@ -58,9 +59,13 @@ export async function appUpdater(updateFromMenu = false): Promise { } await dialog.showMessageBox({ - message: `A new version ${info.version}, of Zulip Desktop is available`, - detail: + message: t.__( + "A new version {{{version}}} of Zulip Desktop is available.", + {version: info.version}, + ), + detail: t.__( "The update will be downloaded in the background. You will be notified when it is ready to be installed.", + ), }); } }); @@ -72,8 +77,11 @@ export async function appUpdater(updateFromMenu = false): Promise { autoUpdater.removeAllListeners(); await dialog.showMessageBox({ - message: "No updates available", - detail: `You are running the latest version of Zulip Desktop.\nVersion: ${app.getVersion()}`, + message: t.__("No updates available."), + detail: t.__( + "You are running the latest version of Zulip Desktop.\nVersion: {{{version}}}", + {version: app.getVersion()}, + ), }); } }); @@ -85,20 +93,20 @@ export async function appUpdater(updateFromMenu = false): Promise { autoUpdater.removeAllListeners(); const messageText = updateAvailable - ? "Unable to download the updates" - : "Unable to check for updates"; + ? t.__("Unable to download the update.") + : t.__("Unable to check for updates."); + const link = "https://zulip.com/apps/"; const {response} = await dialog.showMessageBox({ type: "error", - buttons: ["Manual Download", "Cancel"], + buttons: [t.__("Manual Download"), t.__("Cancel")], message: messageText, - detail: `Error: ${error.message} - -The latest version of Zulip Desktop is available at - -https://zulip.com/apps/. -Current Version: ${app.getVersion()}`, + detail: t.__( + "Error: {{{error}}}\n\nThe latest version of Zulip Desktop is available at:\n{{{link}}}\nCurrent version: {{{version}}}", + {error: error.message, link, version: app.getVersion()}, + ), }); if (response === 0) { - await shell.openExternal("https://zulip.com/apps/"); + await shell.openExternal(link); } } }); @@ -108,10 +116,14 @@ Current Version: ${app.getVersion()}`, // Ask user to update the app const {response} = await dialog.showMessageBox({ type: "question", - buttons: ["Install and Relaunch", "Install Later"], + buttons: [t.__("Install and Relaunch"), t.__("Install Later")], defaultId: 0, - message: `A new update ${event.version} has been downloaded`, - detail: "It will be installed the next time you restart the application", + message: t.__("A new update {{{version}}} has been downloaded.", { + version: event.version, + }), + detail: t.__( + "It will be installed the next time you restart the application.", + ), }); if (response === 0) { quitting = true; diff --git a/app/main/index.ts b/app/main/index.ts index eb5f18c91..e04c59936 100644 --- a/app/main/index.ts +++ b/app/main/index.ts @@ -19,6 +19,7 @@ import windowStateKeeper from "electron-window-state"; import * as ConfigUtil from "../common/config-util.js"; import {bundlePath, bundleUrl, publicPath} from "../common/paths.js"; +import * as t from "../common/translation-util.js"; import type {RendererMessage} from "../common/typed-ipc.js"; import type {MenuProperties} from "../common/types.js"; @@ -318,10 +319,11 @@ function createMainWindow(): BrowserWindow { if (isMainFrame) { const url = new URL(urlString); dialog.showErrorBox( - "Certificate error", - `The server presented an invalid certificate for ${url.origin}: - -${error}`, + t.__("Certificate error"), + t.__( + "The server presented an invalid certificate for {{{origin}}}:\n\n{{{error}}}", + {origin: url.origin, error}, + ), ); } }, diff --git a/app/main/linux-update-util.ts b/app/main/linux-update-util.ts index 0ab0bdaf1..8414fbf94 100644 --- a/app/main/linux-update-util.ts +++ b/app/main/linux-update-util.ts @@ -6,6 +6,7 @@ import {JsonDB} from "node-json-db"; import {DataError} from "node-json-db/dist/lib/Errors"; import Logger from "../common/logger-util.js"; +import * as t from "../common/translation-util.js"; const logger = new Logger({ file: "linux-update-util.log", @@ -57,8 +58,8 @@ function reloadDatabase(): void { if (fs.existsSync(linuxUpdateJsonPath)) { fs.unlinkSync(linuxUpdateJsonPath); dialog.showErrorBox( - "Error saving update notifications.", - "We encountered an error while saving the update notifications.", + t.__("Error saving update notifications"), + t.__("We encountered an error while saving the update notifications."), ); logger.error("Error while JSON parsing updates.json: "); logger.error(error); diff --git a/app/renderer/js/components/webview.ts b/app/renderer/js/components/webview.ts index e51e0af95..90d782f26 100644 --- a/app/renderer/js/components/webview.ts +++ b/app/renderer/js/components/webview.ts @@ -7,6 +7,7 @@ import {app, dialog} from "@electron/remote"; import * as ConfigUtil from "../../../common/config-util.js"; import {type Html, html} from "../../../common/html.js"; +import * as t from "../../../common/translation-util.js"; import type {RendererMessage} from "../../../common/typed-ipc.js"; import type {TabRole} from "../../../common/types.js"; import preloadCss from "../../css/preload.css?raw"; @@ -328,8 +329,8 @@ export default class WebView { this.customCss = null; ConfigUtil.setConfigItem("customCSS", null); - const errorMessage = "The custom css previously set is deleted!"; - dialog.showErrorBox("custom css file deleted!", errorMessage); + const errorMessage = t.__("The custom CSS previously set is deleted."); + dialog.showErrorBox(t.__("Custom CSS file deleted"), errorMessage); return; } diff --git a/app/renderer/js/main.ts b/app/renderer/js/main.ts index 5b229b646..8d09a5b20 100644 --- a/app/renderer/js/main.ts +++ b/app/renderer/js/main.ts @@ -290,12 +290,9 @@ export class ServerManagerView { // ask them before reloading the app const {response} = await dialog.showMessageBox({ type: "question", - buttons: ["Yes", "Later"], + buttons: [t.__("Yes"), t.__("Later")], defaultId: 0, - message: - "New server" + - (domainsAdded.length > 1 ? "s" : "") + - " added. Reload app now?", + message: t.__("New servers added. Reload app now?"), }); if (response === 0) { ipcRenderer.send("reload-full-app"); @@ -823,9 +820,11 @@ export class ServerManagerView { async click() { const {response} = await dialog.showMessageBox({ type: "warning", - buttons: ["YES", "NO"], + buttons: [t.__("Yes"), t.__("No")], defaultId: 0, - message: "Are you sure you want to disconnect this organization?", + message: t.__( + "Are you sure you want to disconnect this organization?", + ), }); if (response === 0) { if (DomainUtil.removeDomain(index)) { @@ -1010,8 +1009,8 @@ export class ServerManagerView { await this.loadProxy(); if (showAlert) { await dialog.showMessageBox({ - message: "Proxy settings saved!", - buttons: ["OK"], + message: t.__("Proxy settings saved."), + buttons: [t.__("OK")], }); ipcRenderer.send("reload-full-app"); } diff --git a/app/renderer/js/pages/preference/general-section.ts b/app/renderer/js/pages/preference/general-section.ts index 1055b7e26..f5c5c0b81 100644 --- a/app/renderer/js/pages/preference/general-section.ts +++ b/app/renderer/js/pages/preference/general-section.ts @@ -455,9 +455,9 @@ export function initGeneralSection({$root}: GeneralSectionProperties): void { async function customCssDialog(): Promise { const showDialogOptions: OpenDialogOptions = { - title: "Select file", + title: t.__("Select file"), properties: ["openFile"], - filters: [{name: "CSS file", extensions: ["css"]}], + filters: [{name: t.__("CSS file"), extensions: ["css"]}], }; const {filePaths, canceled} = @@ -524,7 +524,7 @@ export function initGeneralSection({$root}: GeneralSectionProperties): void { async function downloadFolderDialog(): Promise { const showDialogOptions: OpenDialogOptions = { - title: "Select Download Location", + title: t.__("Select Download Location"), properties: ["openDirectory"], }; @@ -567,9 +567,9 @@ export function initGeneralSection({$root}: GeneralSectionProperties): void { const {response} = await dialog.showMessageBox({ type: "warning", - buttons: ["YES", "NO"], + buttons: [t.__("Yes"), t.__("No")], defaultId: 0, - message: "Are you sure?", + message: t.__("Are you sure?"), detail: clearAppDataMessage, }); if (response === 0) { diff --git a/app/renderer/js/pages/preference/new-server-form.ts b/app/renderer/js/pages/preference/new-server-form.ts index 1c4d49eab..999c88006 100644 --- a/app/renderer/js/pages/preference/new-server-form.ts +++ b/app/renderer/js/pages/preference/new-server-form.ts @@ -71,8 +71,8 @@ export function initNewServerForm({ message: error instanceof Error ? `${error.name}: ${error.message}` - : "Unknown error", - buttons: ["OK"], + : t.__("Unknown error"), + buttons: [t.__("OK")], }); return; } diff --git a/app/renderer/js/pages/preference/server-info-form.ts b/app/renderer/js/pages/preference/server-info-form.ts index cfecefb2f..bdfb88e9a 100644 --- a/app/renderer/js/pages/preference/server-info-form.ts +++ b/app/renderer/js/pages/preference/server-info-form.ts @@ -53,7 +53,7 @@ export function initServerInfoForm(properties: ServerInfoFormProperties): void { $deleteServerButton.addEventListener("click", async () => { const {response} = await dialog.showMessageBox({ type: "warning", - buttons: [t.__("YES"), t.__("NO")], + buttons: [t.__("Yes"), t.__("No")], defaultId: 0, message: t.__("Are you sure you want to disconnect this organization?"), }); diff --git a/app/renderer/js/utils/domain-util.ts b/app/renderer/js/utils/domain-util.ts index a150ba2ad..3a9aa4876 100644 --- a/app/renderer/js/utils/domain-util.ts +++ b/app/renderer/js/utils/domain-util.ts @@ -182,9 +182,10 @@ function reloadDatabase(): void { if (fs.existsSync(domainJsonPath)) { fs.unlinkSync(domainJsonPath); dialog.showErrorBox( - "Error saving new organization", - "There seems to be error while saving new organization, " + - "you may have to re-add your previous organizations back.", + t.__("Error saving new organization"), + t.__( + "There was an error while saving the new organization. You may have to add your previous organizations again.", + ), ); logger.error("Error while JSON parsing domain.json: "); logger.error(error); diff --git a/public/translations/en.json b/public/translations/en.json index f0178c069..776fda9b6 100644 --- a/public/translations/en.json +++ b/public/translations/en.json @@ -1,4 +1,6 @@ { + "A new update {{{version}}} has been downloaded.": "A new update {{{version}}} has been downloaded.", + "A new version {{{version}}} of Zulip Desktop is available.": "A new version {{{version}}} of Zulip Desktop is available.", "About": "About", "About Zulip": "About Zulip", "Actual Size": "Actual Size", @@ -14,12 +16,16 @@ "Appearance": "Appearance", "Application Shortcuts": "Application Shortcuts", "Are you sure you want to disconnect this organization?": "Are you sure you want to disconnect this organization?", + "Are you sure?": "Are you sure?", "Ask where to save files before downloading": "Ask where to save files before downloading", "Auto hide Menu bar": "Auto hide Menu bar", "Auto hide menu bar (Press Alt key to display)": "Auto hide menu bar (Press Alt key to display)", "Available under the {{{link}}}Apache 2.0 License{{{endLink}}}": "Available under the {{{link}}}Apache 2.0 License{{{endLink}}}", "Back": "Back", "Bounce dock on new private message": "Bounce dock on new private message", + "CSS file": "CSS file", + "Cancel": "Cancel", + "Certificate error": "Certificate error", "Change": "Change", "Change the language from System Preferences → Keyboard → Text → Spelling.": "Change the language from System Preferences → Keyboard → Text → Spelling.", "Check for Updates": "Check for Updates", @@ -34,6 +40,7 @@ "Copy Link": "Copy Link", "Copy Zulip URL": "Copy Zulip URL", "Create a new organization": "Create a new organization", + "Custom CSS file deleted": "Custom CSS file deleted", "Cut": "Cut", "Default download location": "Default download location", "Delete": "Delete", @@ -50,6 +57,9 @@ "Enable error reporting (requires restart)": "Enable error reporting (requires restart)", "Enable spellchecker (requires restart)": "Enable spellchecker (requires restart)", "Enter Full Screen": "Enter Full Screen", + "Error saving new organization": "Error saving new organization", + "Error saving update notifications": "Error saving update notifications", + "Error: {{{error}}}\n\nThe latest version of Zulip Desktop is available at:\n{{{link}}}\nCurrent version: {{{version}}}": "Error: {{{error}}}\n\nThe latest version of Zulip Desktop is available at:\n{{{link}}}\nCurrent version: {{{version}}}", "Factory Reset": "Factory Reset", "Factory Reset Data": "Factory Reset Data", "File": "File", @@ -69,20 +79,28 @@ "Hide Zulip": "Hide Zulip", "History": "History", "History Shortcuts": "History Shortcuts", + "Install Later": "Install Later", + "Install and Relaunch": "Install and Relaunch", + "It will be installed the next time you restart the application.": "It will be installed the next time you restart the application.", "Keyboard Shortcuts": "Keyboard Shortcuts", + "Later": "Later", "Loading": "Loading", "Log Out": "Log Out", "Log Out of Organization": "Log Out of Organization", "Look Up": "Look Up", "Maintained by {{{link}}}Zulip{{{endLink}}}": "Maintained by {{{link}}}Zulip{{{endLink}}}", + "Manual Download": "Manual Download", "Manual proxy configuration": "Manual proxy configuration", "Minimize": "Minimize", "Mute all sounds from Zulip": "Mute all sounds from Zulip", - "NO": "NO", "Network": "Network", "Network and Proxy Settings": "Network and Proxy Settings", + "New servers added. Reload app now?": "New servers added. Reload app now?", + "No": "No", "No Suggestion Found": "No Suggestion Found", + "No updates available.": "No updates available.", "Notification settings": "Notification settings", + "OK": "OK", "OR": "OR", "On macOS, the OS spellchecker is used.": "On macOS, the OS spellchecker is used.", "Organization URL": "Organization URL", @@ -92,6 +110,7 @@ "Proxy": "Proxy", "Proxy bypass rules": "Proxy bypass rules", "Proxy rules": "Proxy rules", + "Proxy settings saved.": "Proxy settings saved.", "Quit": "Quit", "Quit Zulip": "Quit Zulip", "Quit when the window is closed": "Quit when the window is closed", @@ -103,6 +122,8 @@ "Reset the application, thus deleting all the connected organizations and accounts.": "Reset the application, thus deleting all the connected organizations and accounts.", "Save": "Save", "Select All": "Select All", + "Select Download Location": "Select Download Location", + "Select file": "Select file", "Services": "Services", "Settings": "Settings", "Shortcuts": "Shortcuts", @@ -114,6 +135,10 @@ "Start app at login": "Start app at login", "Switch to Next Organization": "Switch to Next Organization", "Switch to Previous Organization": "Switch to Previous Organization", + "The custom CSS previously set is deleted.": "The custom CSS previously set is deleted.", + "The server presented an invalid certificate for {{{origin}}}:\n\n{{{error}}}": "The server presented an invalid certificate for {{{origin}}}:\n\n{{{error}}}", + "The update will be downloaded in the background. You will be notified when it is ready to be installed.": "The update will be downloaded in the background. You will be notified when it is ready to be installed.", + "There was an error while saving the new organization. You may have to add your previous organizations again.": "There was an error while saving the new organization. You may have to add your previous organizations again.", "These desktop app shortcuts extend the Zulip webapp's": "These desktop app shortcuts extend the Zulip webapp's", "Tip": "Tip", "Toggle DevTools for Active Tab": "Toggle DevTools for Active Tab", @@ -123,15 +148,20 @@ "Toggle Sidebar": "Toggle Sidebar", "Toggle Tray Icon": "Toggle Tray Icon", "Tools": "Tools", + "Unable to check for updates.": "Unable to check for updates.", + "Unable to download the update.": "Unable to download the update.", "Undo": "Undo", "Unhide": "Unhide", + "Unknown error": "Unknown error", "Upload": "Upload", "Use system proxy settings (requires restart)": "Use system proxy settings (requires restart)", "View": "View", "View Shortcuts": "View Shortcuts", + "We encountered an error while saving the update notifications.": "We encountered an error while saving the update notifications.", "Window": "Window", "Window Shortcuts": "Window Shortcuts", - "YES": "YES", + "Yes": "Yes", + "You are running the latest version of Zulip Desktop.\nVersion: {{{version}}}": "You are running the latest version of Zulip Desktop.\nVersion: {{{version}}}", "You can select a maximum of 3 languages for spellchecking.": "You can select a maximum of 3 languages for spellchecking.", "Zoom In": "Zoom In", "Zoom Out": "Zoom Out",