Skip to content

Commit da7e026

Browse files
committed
Mark dialog strings for translation.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent c70f6df commit da7e026

File tree

10 files changed

+92
-46
lines changed

10 files changed

+92
-46
lines changed

app/main/autoupdater.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from "electron-updater";
1111

1212
import * as ConfigUtil from "../common/config-util.js";
13+
import * as t from "../common/translation-util.js";
1314

1415
import {linuxUpdateNotification} from "./linuxupdater.js"; // Required only in case of linux
1516

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

6061
await dialog.showMessageBox({
61-
message: `A new version ${info.version}, of Zulip Desktop is available`,
62-
detail:
62+
message: t.__(
63+
"A new version {{{version}}} of Zulip Desktop is available.",
64+
{version: info.version},
65+
),
66+
detail: t.__(
6367
"The update will be downloaded in the background. You will be notified when it is ready to be installed.",
68+
),
6469
});
6570
}
6671
});
@@ -72,8 +77,11 @@ export async function appUpdater(updateFromMenu = false): Promise<void> {
7277
autoUpdater.removeAllListeners();
7378

7479
await dialog.showMessageBox({
75-
message: "No updates available",
76-
detail: `You are running the latest version of Zulip Desktop.\nVersion: ${app.getVersion()}`,
80+
message: t.__("No updates available."),
81+
detail: t.__(
82+
"You are running the latest version of Zulip Desktop.\nVersion: {{{version}}}",
83+
{version: app.getVersion()},
84+
),
7785
});
7886
}
7987
});
@@ -85,20 +93,20 @@ export async function appUpdater(updateFromMenu = false): Promise<void> {
8593
autoUpdater.removeAllListeners();
8694

8795
const messageText = updateAvailable
88-
? "Unable to download the updates"
89-
: "Unable to check for updates";
96+
? t.__("Unable to download the update.")
97+
: t.__("Unable to check for updates.");
98+
const link = "https://zulip.com/apps/";
9099
const {response} = await dialog.showMessageBox({
91100
type: "error",
92-
buttons: ["Manual Download", "Cancel"],
101+
buttons: [t.__("Manual Download"), t.__("Cancel")],
93102
message: messageText,
94-
detail: `Error: ${error.message}
95-
96-
The latest version of Zulip Desktop is available at -
97-
https://zulip.com/apps/.
98-
Current Version: ${app.getVersion()}`,
103+
detail: t.__(
104+
"Error: {{{error}}}\n\nThe latest version of Zulip Desktop is available at:\n{{{link}}}\nCurrent version: {{{version}}}",
105+
{error: error.message, link, version: app.getVersion()},
106+
),
99107
});
100108
if (response === 0) {
101-
await shell.openExternal("https://zulip.com/apps/");
109+
await shell.openExternal(link);
102110
}
103111
}
104112
});
@@ -108,10 +116,14 @@ Current Version: ${app.getVersion()}`,
108116
// Ask user to update the app
109117
const {response} = await dialog.showMessageBox({
110118
type: "question",
111-
buttons: ["Install and Relaunch", "Install Later"],
119+
buttons: [t.__("Install and Relaunch"), t.__("Install Later")],
112120
defaultId: 0,
113-
message: `A new update ${event.version} has been downloaded`,
114-
detail: "It will be installed the next time you restart the application",
121+
message: t.__("A new update {{{version}}} has been downloaded.", {
122+
version: event.version,
123+
}),
124+
detail: t.__(
125+
"It will be installed the next time you restart the application.",
126+
),
115127
});
116128
if (response === 0) {
117129
quitting = true;

app/main/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import windowStateKeeper from "electron-window-state";
1919

2020
import * as ConfigUtil from "../common/config-util.js";
2121
import {bundlePath, bundleUrl, publicPath} from "../common/paths.js";
22+
import * as t from "../common/translation-util.js";
2223
import type {RendererMessage} from "../common/typed-ipc.js";
2324
import type {MenuProperties} from "../common/types.js";
2425

@@ -318,10 +319,11 @@ function createMainWindow(): BrowserWindow {
318319
if (isMainFrame) {
319320
const url = new URL(urlString);
320321
dialog.showErrorBox(
321-
"Certificate error",
322-
`The server presented an invalid certificate for ${url.origin}:
323-
324-
${error}`,
322+
t.__("Certificate error"),
323+
t.__(
324+
"The server presented an invalid certificate for {{{origin}}}:\n\n{{{error}}}",
325+
{origin: url.origin, error},
326+
),
325327
);
326328
}
327329
},

app/main/linux-update-util.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {JsonDB} from "node-json-db";
66
import {DataError} from "node-json-db/dist/lib/Errors";
77

88
import Logger from "../common/logger-util.js";
9+
import * as t from "../common/translation-util.js";
910

1011
const logger = new Logger({
1112
file: "linux-update-util.log",
@@ -57,8 +58,8 @@ function reloadDatabase(): void {
5758
if (fs.existsSync(linuxUpdateJsonPath)) {
5859
fs.unlinkSync(linuxUpdateJsonPath);
5960
dialog.showErrorBox(
60-
"Error saving update notifications.",
61-
"We encountered an error while saving the update notifications.",
61+
t.__("Error saving update notifications"),
62+
t.__("We encountered an error while saving the update notifications."),
6263
);
6364
logger.error("Error while JSON parsing updates.json: ");
6465
logger.error(error);

app/renderer/js/components/webview.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {app, dialog} from "@electron/remote";
77

88
import * as ConfigUtil from "../../../common/config-util.js";
99
import {type Html, html} from "../../../common/html.js";
10+
import * as t from "../../../common/translation-util.js";
1011
import type {RendererMessage} from "../../../common/typed-ipc.js";
1112
import type {TabRole} from "../../../common/types.js";
1213
import preloadCss from "../../css/preload.css?raw";
@@ -328,8 +329,8 @@ export default class WebView {
328329
this.customCss = null;
329330
ConfigUtil.setConfigItem("customCSS", null);
330331

331-
const errorMessage = "The custom css previously set is deleted!";
332-
dialog.showErrorBox("custom css file deleted!", errorMessage);
332+
const errorMessage = t.__("The custom CSS previously set is deleted.");
333+
dialog.showErrorBox(t.__("Custom CSS file deleted"), errorMessage);
333334
return;
334335
}
335336

app/renderer/js/main.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,9 @@ export class ServerManagerView {
290290
// ask them before reloading the app
291291
const {response} = await dialog.showMessageBox({
292292
type: "question",
293-
buttons: ["Yes", "Later"],
293+
buttons: [t.__("Yes"), t.__("Later")],
294294
defaultId: 0,
295-
message:
296-
"New server" +
297-
(domainsAdded.length > 1 ? "s" : "") +
298-
" added. Reload app now?",
295+
message: t.__("New servers added. Reload app now?"),
299296
});
300297
if (response === 0) {
301298
ipcRenderer.send("reload-full-app");
@@ -823,9 +820,11 @@ export class ServerManagerView {
823820
async click() {
824821
const {response} = await dialog.showMessageBox({
825822
type: "warning",
826-
buttons: ["YES", "NO"],
823+
buttons: [t.__("Yes"), t.__("No")],
827824
defaultId: 0,
828-
message: "Are you sure you want to disconnect this organization?",
825+
message: t.__(
826+
"Are you sure you want to disconnect this organization?",
827+
),
829828
});
830829
if (response === 0) {
831830
if (DomainUtil.removeDomain(index)) {
@@ -1010,8 +1009,8 @@ export class ServerManagerView {
10101009
await this.loadProxy();
10111010
if (showAlert) {
10121011
await dialog.showMessageBox({
1013-
message: "Proxy settings saved!",
1014-
buttons: ["OK"],
1012+
message: t.__("Proxy settings saved."),
1013+
buttons: [t.__("OK")],
10151014
});
10161015
ipcRenderer.send("reload-full-app");
10171016
}

app/renderer/js/pages/preference/general-section.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,9 @@ export function initGeneralSection({$root}: GeneralSectionProperties): void {
455455

456456
async function customCssDialog(): Promise<void> {
457457
const showDialogOptions: OpenDialogOptions = {
458-
title: "Select file",
458+
title: t.__("Select file"),
459459
properties: ["openFile"],
460-
filters: [{name: "CSS file", extensions: ["css"]}],
460+
filters: [{name: t.__("CSS file"), extensions: ["css"]}],
461461
};
462462

463463
const {filePaths, canceled} =
@@ -524,7 +524,7 @@ export function initGeneralSection({$root}: GeneralSectionProperties): void {
524524

525525
async function downloadFolderDialog(): Promise<void> {
526526
const showDialogOptions: OpenDialogOptions = {
527-
title: "Select Download Location",
527+
title: t.__("Select Download Location"),
528528
properties: ["openDirectory"],
529529
};
530530

@@ -567,9 +567,9 @@ export function initGeneralSection({$root}: GeneralSectionProperties): void {
567567

568568
const {response} = await dialog.showMessageBox({
569569
type: "warning",
570-
buttons: ["YES", "NO"],
570+
buttons: [t.__("Yes"), t.__("No")],
571571
defaultId: 0,
572-
message: "Are you sure?",
572+
message: t.__("Are you sure?"),
573573
detail: clearAppDataMessage,
574574
});
575575
if (response === 0) {

app/renderer/js/pages/preference/new-server-form.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export function initNewServerForm({
7171
message:
7272
error instanceof Error
7373
? `${error.name}: ${error.message}`
74-
: "Unknown error",
75-
buttons: ["OK"],
74+
: t.__("Unknown error"),
75+
buttons: [t.__("OK")],
7676
});
7777
return;
7878
}

app/renderer/js/pages/preference/server-info-form.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function initServerInfoForm(properties: ServerInfoFormProperties): void {
5353
$deleteServerButton.addEventListener("click", async () => {
5454
const {response} = await dialog.showMessageBox({
5555
type: "warning",
56-
buttons: [t.__("YES"), t.__("NO")],
56+
buttons: [t.__("Yes"), t.__("No")],
5757
defaultId: 0,
5858
message: t.__("Are you sure you want to disconnect this organization?"),
5959
});

app/renderer/js/utils/domain-util.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ function reloadDatabase(): void {
182182
if (fs.existsSync(domainJsonPath)) {
183183
fs.unlinkSync(domainJsonPath);
184184
dialog.showErrorBox(
185-
"Error saving new organization",
186-
"There seems to be error while saving new organization, " +
187-
"you may have to re-add your previous organizations back.",
185+
t.__("Error saving new organization"),
186+
t.__(
187+
"There was an error while saving the new organization. You may have to add your previous organizations again.",
188+
),
188189
);
189190
logger.error("Error while JSON parsing domain.json: ");
190191
logger.error(error);

public/translations/en.json

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"A new update {{{version}}} has been downloaded.": "A new update {{{version}}} has been downloaded.",
3+
"A new version {{{version}}} of Zulip Desktop is available.": "A new version {{{version}}} of Zulip Desktop is available.",
24
"About": "About",
35
"About Zulip": "About Zulip",
46
"Actual Size": "Actual Size",
@@ -14,12 +16,16 @@
1416
"Appearance": "Appearance",
1517
"Application Shortcuts": "Application Shortcuts",
1618
"Are you sure you want to disconnect this organization?": "Are you sure you want to disconnect this organization?",
19+
"Are you sure?": "Are you sure?",
1720
"Ask where to save files before downloading": "Ask where to save files before downloading",
1821
"Auto hide Menu bar": "Auto hide Menu bar",
1922
"Auto hide menu bar (Press Alt key to display)": "Auto hide menu bar (Press Alt key to display)",
2023
"Available under the {{{link}}}Apache 2.0 License{{{endLink}}}": "Available under the {{{link}}}Apache 2.0 License{{{endLink}}}",
2124
"Back": "Back",
2225
"Bounce dock on new private message": "Bounce dock on new private message",
26+
"CSS file": "CSS file",
27+
"Cancel": "Cancel",
28+
"Certificate error": "Certificate error",
2329
"Change": "Change",
2430
"Change the language from System Preferences → Keyboard → Text → Spelling.": "Change the language from System Preferences → Keyboard → Text → Spelling.",
2531
"Check for Updates": "Check for Updates",
@@ -34,6 +40,7 @@
3440
"Copy Link": "Copy Link",
3541
"Copy Zulip URL": "Copy Zulip URL",
3642
"Create a new organization": "Create a new organization",
43+
"Custom CSS file deleted": "Custom CSS file deleted",
3744
"Cut": "Cut",
3845
"Default download location": "Default download location",
3946
"Delete": "Delete",
@@ -50,6 +57,9 @@
5057
"Enable error reporting (requires restart)": "Enable error reporting (requires restart)",
5158
"Enable spellchecker (requires restart)": "Enable spellchecker (requires restart)",
5259
"Enter Full Screen": "Enter Full Screen",
60+
"Error saving new organization": "Error saving new organization",
61+
"Error saving update notifications": "Error saving update notifications",
62+
"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}}}",
5363
"Factory Reset": "Factory Reset",
5464
"Factory Reset Data": "Factory Reset Data",
5565
"File": "File",
@@ -69,20 +79,28 @@
6979
"Hide Zulip": "Hide Zulip",
7080
"History": "History",
7181
"History Shortcuts": "History Shortcuts",
82+
"Install Later": "Install Later",
83+
"Install and Relaunch": "Install and Relaunch",
84+
"It will be installed the next time you restart the application.": "It will be installed the next time you restart the application.",
7285
"Keyboard Shortcuts": "Keyboard Shortcuts",
86+
"Later": "Later",
7387
"Loading": "Loading",
7488
"Log Out": "Log Out",
7589
"Log Out of Organization": "Log Out of Organization",
7690
"Look Up": "Look Up",
7791
"Maintained by {{{link}}}Zulip{{{endLink}}}": "Maintained by {{{link}}}Zulip{{{endLink}}}",
92+
"Manual Download": "Manual Download",
7893
"Manual proxy configuration": "Manual proxy configuration",
7994
"Minimize": "Minimize",
8095
"Mute all sounds from Zulip": "Mute all sounds from Zulip",
81-
"NO": "NO",
8296
"Network": "Network",
8397
"Network and Proxy Settings": "Network and Proxy Settings",
98+
"New servers added. Reload app now?": "New servers added. Reload app now?",
99+
"No": "No",
84100
"No Suggestion Found": "No Suggestion Found",
101+
"No updates available.": "No updates available.",
85102
"Notification settings": "Notification settings",
103+
"OK": "OK",
86104
"OR": "OR",
87105
"On macOS, the OS spellchecker is used.": "On macOS, the OS spellchecker is used.",
88106
"Organization URL": "Organization URL",
@@ -92,6 +110,7 @@
92110
"Proxy": "Proxy",
93111
"Proxy bypass rules": "Proxy bypass rules",
94112
"Proxy rules": "Proxy rules",
113+
"Proxy settings saved.": "Proxy settings saved.",
95114
"Quit": "Quit",
96115
"Quit Zulip": "Quit Zulip",
97116
"Quit when the window is closed": "Quit when the window is closed",
@@ -103,6 +122,8 @@
103122
"Reset the application, thus deleting all the connected organizations and accounts.": "Reset the application, thus deleting all the connected organizations and accounts.",
104123
"Save": "Save",
105124
"Select All": "Select All",
125+
"Select Download Location": "Select Download Location",
126+
"Select file": "Select file",
106127
"Services": "Services",
107128
"Settings": "Settings",
108129
"Shortcuts": "Shortcuts",
@@ -114,6 +135,10 @@
114135
"Start app at login": "Start app at login",
115136
"Switch to Next Organization": "Switch to Next Organization",
116137
"Switch to Previous Organization": "Switch to Previous Organization",
138+
"The custom CSS previously set is deleted.": "The custom CSS previously set is deleted.",
139+
"The server presented an invalid certificate for {{{origin}}}:\n\n{{{error}}}": "The server presented an invalid certificate for {{{origin}}}:\n\n{{{error}}}",
140+
"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.",
141+
"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.",
117142
"These desktop app shortcuts extend the Zulip webapp's": "These desktop app shortcuts extend the Zulip webapp's",
118143
"Tip": "Tip",
119144
"Toggle DevTools for Active Tab": "Toggle DevTools for Active Tab",
@@ -123,15 +148,20 @@
123148
"Toggle Sidebar": "Toggle Sidebar",
124149
"Toggle Tray Icon": "Toggle Tray Icon",
125150
"Tools": "Tools",
151+
"Unable to check for updates.": "Unable to check for updates.",
152+
"Unable to download the update.": "Unable to download the update.",
126153
"Undo": "Undo",
127154
"Unhide": "Unhide",
155+
"Unknown error": "Unknown error",
128156
"Upload": "Upload",
129157
"Use system proxy settings (requires restart)": "Use system proxy settings (requires restart)",
130158
"View": "View",
131159
"View Shortcuts": "View Shortcuts",
160+
"We encountered an error while saving the update notifications.": "We encountered an error while saving the update notifications.",
132161
"Window": "Window",
133162
"Window Shortcuts": "Window Shortcuts",
134-
"YES": "YES",
163+
"Yes": "Yes",
164+
"You are running the latest version of Zulip Desktop.\nVersion: {{{version}}}": "You are running the latest version of Zulip Desktop.\nVersion: {{{version}}}",
135165
"You can select a maximum of 3 languages for spellchecking.": "You can select a maximum of 3 languages for spellchecking.",
136166
"Zoom In": "Zoom In",
137167
"Zoom Out": "Zoom Out",

0 commit comments

Comments
 (0)