mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-23 03:31:56 +00:00
nav: Statically mark navigation items for translation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
@@ -9,15 +9,15 @@ type PreferenceNavigationProperties = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default class PreferenceNavigation {
|
export default class PreferenceNavigation {
|
||||||
navigationItems: NavigationItem[];
|
navigationItems: Array<{navigationItem: NavigationItem; label: string}>;
|
||||||
$el: Element;
|
$el: Element;
|
||||||
constructor(private readonly properties: PreferenceNavigationProperties) {
|
constructor(private readonly properties: PreferenceNavigationProperties) {
|
||||||
this.navigationItems = [
|
this.navigationItems = [
|
||||||
"General",
|
{navigationItem: "General", label: t.__("General")},
|
||||||
"Network",
|
{navigationItem: "Network", label: t.__("Network")},
|
||||||
"AddServer",
|
{navigationItem: "AddServer", label: t.__("Add Organization")},
|
||||||
"Organizations",
|
{navigationItem: "Organizations", label: t.__("Organizations")},
|
||||||
"Shortcuts",
|
{navigationItem: "Shortcuts", label: t.__("Shortcuts")},
|
||||||
];
|
];
|
||||||
|
|
||||||
this.$el = generateNodeFromHtml(this.templateHtml());
|
this.$el = generateNodeFromHtml(this.templateHtml());
|
||||||
@@ -28,11 +28,8 @@ export default class PreferenceNavigation {
|
|||||||
templateHtml(): Html {
|
templateHtml(): Html {
|
||||||
const navigationItemsHtml = html``.join(
|
const navigationItemsHtml = html``.join(
|
||||||
this.navigationItems.map(
|
this.navigationItems.map(
|
||||||
(navigationItem) => html`
|
({navigationItem, label}) =>
|
||||||
<div class="nav" id="nav-${navigationItem}">
|
html`<div class="nav" id="nav-${navigationItem}">${label}</div>`,
|
||||||
${t.__(navigationItem)}
|
|
||||||
</div>
|
|
||||||
`,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -45,7 +42,7 @@ export default class PreferenceNavigation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerListeners(): void {
|
registerListeners(): void {
|
||||||
for (const navigationItem of this.navigationItems) {
|
for (const {navigationItem} of this.navigationItems) {
|
||||||
const $item = this.$el.querySelector(
|
const $item = this.$el.querySelector(
|
||||||
`#nav-${CSS.escape(navigationItem)}`,
|
`#nav-${CSS.escape(navigationItem)}`,
|
||||||
)!;
|
)!;
|
||||||
@@ -56,7 +53,7 @@ export default class PreferenceNavigation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select(navigationItemToSelect: NavigationItem): void {
|
select(navigationItemToSelect: NavigationItem): void {
|
||||||
for (const navigationItem of this.navigationItems) {
|
for (const {navigationItem} of this.navigationItems) {
|
||||||
if (navigationItem === navigationItemToSelect) {
|
if (navigationItem === navigationItemToSelect) {
|
||||||
this.activate(navigationItem);
|
this.activate(navigationItem);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
"Add Organization": "Add Organization",
|
"Add Organization": "Add Organization",
|
||||||
"Add a Zulip organization": "Add a Zulip organization",
|
"Add a Zulip organization": "Add a Zulip organization",
|
||||||
"Add custom CSS": "Add custom CSS",
|
"Add custom CSS": "Add custom CSS",
|
||||||
"AddServer": "AddServer",
|
|
||||||
"Advanced": "Advanced",
|
"Advanced": "Advanced",
|
||||||
"All the connected organizations will appear here.": "All the connected organizations will appear here.",
|
"All the connected organizations will appear here.": "All the connected organizations will appear here.",
|
||||||
"Always start minimized": "Always start minimized",
|
"Always start minimized": "Always start minimized",
|
||||||
|
Reference in New Issue
Block a user