Skip to content

Commit

Permalink
Mark dialog strings for translation.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Dec 2, 2024
1 parent c70f6df commit da7e026
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 46 deletions.
44 changes: 28 additions & 16 deletions app/main/autoupdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -58,9 +59,13 @@ export async function appUpdater(updateFromMenu = false): Promise<void> {
}

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.",
),
});
}
});
Expand All @@ -72,8 +77,11 @@ export async function appUpdater(updateFromMenu = false): Promise<void> {
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()},
),
});
}
});
Expand All @@ -85,20 +93,20 @@ export async function appUpdater(updateFromMenu = false): Promise<void> {
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);
}
}
});
Expand All @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions app/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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},
),
);
}
},
Expand Down
5 changes: 3 additions & 2 deletions app/main/linux-update-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions app/renderer/js/components/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}

Expand Down
17 changes: 8 additions & 9 deletions app/renderer/js/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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");
}
Expand Down
10 changes: 5 additions & 5 deletions app/renderer/js/pages/preference/general-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ export function initGeneralSection({$root}: GeneralSectionProperties): void {

async function customCssDialog(): Promise<void> {
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} =
Expand Down Expand Up @@ -524,7 +524,7 @@ export function initGeneralSection({$root}: GeneralSectionProperties): void {

async function downloadFolderDialog(): Promise<void> {
const showDialogOptions: OpenDialogOptions = {
title: "Select Download Location",
title: t.__("Select Download Location"),
properties: ["openDirectory"],
};

Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions app/renderer/js/pages/preference/new-server-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/js/pages/preference/server-info-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?"),
});
Expand Down
7 changes: 4 additions & 3 deletions app/renderer/js/utils/domain-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
34 changes: 32 additions & 2 deletions public/translations/en.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit da7e026

Please sign in to comment.