Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark more strings for translation #1397

Merged
merged 7 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export type ServerConfig = {
};

export type TabRole = "server" | "function";
export type TabPage = "Settings" | "About";

export type TabData = {
role: TabRole;
name: string;
page?: TabPage;
label: string;
index: number;
};
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
12 changes: 7 additions & 5 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 Expand Up @@ -428,7 +430,7 @@ ${error}`,
AppMenu.setMenu(properties);
if (properties.activeTabIndex !== undefined) {
const activeTab = properties.tabs[properties.activeTabIndex];
mainWindow.setTitle(`Zulip - ${activeTab.name}`);
mainWindow.setTitle(`Zulip - ${activeTab.label}`);
}
});

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
4 changes: 2 additions & 2 deletions app/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,12 @@ function getWindowSubmenu(
if (tab === undefined) continue;

// Do not add functional tab settings to list of windows in menu bar
if (tab.role === "function" && tab.name === "Settings") {
if (tab.role === "function" && tab.page === "Settings") {
continue;
}

initialSubmenu.push({
label: tab.name,
label: tab.label,
accelerator:
tab.role === "function" ? "" : `${shortcutKey} + ${tab.index + 1}`,
checked: tab.index === activeTabIndex,
Expand Down
17 changes: 0 additions & 17 deletions app/renderer/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,4 @@
<div class="about" hidden>
<img class="logo" src="../resources/zulip.png" />
<p class="detail" id="version"></p>
<div class="maintenance-info">
<p class="detail maintainer">
Maintained by
<a href="https://zulip.com" target="_blank" rel="noopener noreferrer"
>Zulip</a
>
</p>
<p class="detail license">
Available under the
<a
href="https://github.com/zulip/zulip-desktop/blob/main/LICENSE"
target="_blank"
rel="noopener noreferrer"
>Apache 2.0 License</a
>
</p>
</div>
</div>
1 change: 0 additions & 1 deletion app/renderer/css/about.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
}

.maintenance-info {
cursor: pointer;
position: absolute;
width: 100%;
left: 0;
Expand Down
4 changes: 3 additions & 1 deletion app/renderer/js/components/functional-tab.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {type Html, html} from "../../../common/html.js";
import type {TabPage} from "../../../common/types.js";

import {generateNodeFromHtml} from "./base.js";
import Tab, {type TabProperties} from "./tab.js";

export type FunctionalTabProperties = {
$view: Element;
page: TabPage;
} & TabProperties;

export default class FunctionalTab extends Tab {
Expand All @@ -17,7 +19,7 @@ export default class FunctionalTab extends Tab {

this.$view = $view;
this.$el = generateNodeFromHtml(this.templateHtml());
if (this.properties.name !== "Settings") {
if (properties.page !== "Settings") {
this.properties.$root.append(this.$el);
this.$closeButton = this.$el.querySelector(".server-tab-badge")!;
this.registerListeners();
Expand Down
8 changes: 4 additions & 4 deletions app/renderer/js/components/server-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class ServerTab extends Tab {
return html`
<div class="tab" data-tab-id="${this.properties.tabIndex}">
<div class="server-tooltip" style="display:none">
${this.properties.name}
${this.properties.label}
</div>
<div class="server-tab-badge"></div>
<div class="server-tab">
Expand All @@ -60,9 +60,9 @@ export default class ServerTab extends Tab {
`;
}

setName(name: string): void {
this.properties.name = name;
this.$name.textContent = name;
setLabel(label: string): void {
this.properties.label = label;
this.$name.textContent = label;
}

setIcon(icon: string): void {
Expand Down
5 changes: 3 additions & 2 deletions app/renderer/js/components/tab.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type {TabRole} from "../../../common/types.js";
import type {TabPage, TabRole} from "../../../common/types.js";

export type TabProperties = {
role: TabRole;
page?: TabPage;
icon?: string;
name: string;
label: string;
$root: Element;
onClick: () => void;
index: number;
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
Loading
Loading