Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(desktop): localize the workspace tab bar menu (#9099)

moxi25344caf571aab9f
diff --git a/apps/desktop/src/renderer/src/components/tab-bar.test.tsx b/apps/desktop/src/renderer/src/components/tab-bar.test.tsx
index 2b92783fb7..4dddc7dc6d 100644
--- a/apps/desktop/src/renderer/src/components/tab-bar.test.tsx
+++ b/apps/desktop/src/renderer/src/components/tab-bar.test.tsx
@@ -1,11 +1,16 @@
import { afterAll, describe, expect, it, vi, beforeEach } from "vitest";
+import type { ReactElement } from "react";
import {
- render,
+ render as renderRtl,
renderHook,
fireEvent,
waitFor,
within,
+ type RenderResult,
} from "@testing-library/react";
+import { I18nProvider } from "@multica/core/i18n/react";
+import type { SupportedLocale } from "@multica/core/i18n";
+import { RESOURCES } from "@multica/views/locales";
import { useScrollFade } from "@multica/ui/hooks/use-scroll-fade";
import { SIDEBAR_WRAPPER_FILL_CLASS } from "@multica/ui/components/ui/sidebar";
@@ -94,6 +99,25 @@ vi.mock("@multica/views/layout", () => ({
import { TabBar } from "./tab-bar";
+function render(
+ ui: ReactElement,
+ locale: SupportedLocale = "en",
+): RenderResult {
+ return renderRtl(
+ <I18nProvider locale={locale} resources={RESOURCES}>
+ {ui}
+ </I18nProvider>,
+ );
+}
+
+function englishTabBar() {
+ return (
+ <I18nProvider locale="en" resources={RESOURCES}>
+ <TabBar />
+ </I18nProvider>
+ );
+}
+
function reset() {
state.activeWorkspaceSlug = "acme";
state.byWorkspace = {
@@ -409,7 +433,7 @@ describe("TabBar overflow", () => {
tabScroller.scrollLeft = 40;
state.byWorkspace.acme.activeTabId = "t5";
- rerender(<TabBar />);
+ rerender(englishTabBar());
expect(tabScroller.scrollLeft).toBe(222);
});
@@ -462,7 +486,7 @@ describe("TabBar overflow", () => {
},
];
state.byWorkspace.acme.activeTabId = "t6";
- rerender(<TabBar />);
+ rerender(englishTabBar());
expect(getByLabelText("Tab 6")).toHaveAttribute(
"data-tab-entering",
@@ -517,7 +541,7 @@ describe("TabBar overflow", () => {
pinned: false,
},
];
- rerender(<TabBar />);
+ rerender(englishTabBar());
expect(tabScroller.scrollLeft).toBe(40);
expect(scrollTo).not.toHaveBeenCalled();
@@ -581,3 +605,93 @@ describe("TabBar context menu", () => {
});
});
+
+describe("TabBar locale", () => {
+ const menus = {
+ "zh-Hans": {
+ pin: "固定标签页",
+ unpin: "取消固定标签页",
+ close: "关闭标签页",
+ closeOthers: "关闭其他标签页",
+ openWindow: "在新窗口打开",
+ newTab: "新建标签页",
+ pinned: "Issues(已固定)",
+ },
+ ja: {
+ pin: "タブをピン留め",
+ unpin: "タブのピン留めを解除",
+ close: "タブを閉じる",
+ closeOthers: "他のタブを閉じる",
+ openWindow: "新しいウィンドウで開く",
+ newTab: "新しいタブ",
+ pinned: "Issues(ピン留め)",
+ },
+ ko: {
+ pin: "탭 고정",
+ unpin: "탭 고정 해제",
+ close: "탭 닫기",
+ closeOthers: "다른 탭 닫기",
+ openWindow: "새 창에서 열기",
+ newTab: "새 탭",
+ pinned: "Issues (고정됨)",
+ },
+ fr: {
+ pin: "Épingler l'onglet",
+ unpin: "Désépingler l'onglet",
+ close: "Fermer l'onglet",
+ closeOthers: "Fermer les autres onglets",
+ openWindow: "Ouvrir dans une nouvelle fenêtre",
+ newTab: "Nouvel onglet",
+ pinned: "Issues (épinglé)",
+ },
+ } as const satisfies Record<
+ Exclude<SupportedLocale, "en">,
+ {
+ pin: string;
+ unpin: string;
+ close: string;
+ closeOthers: string;
+ openWindow: string;
+ newTab: string;
+ pinned: string;
+ }
+ >;
+
+ for (const [locale, copy] of Object.entries(menus)) {
+ it(`renders the tab menu in ${locale}, not English`, async () => {
+ state.byWorkspace.acme.tabs = [
+ {
+ id: "tA",
+ url: "/acme/issues/issue-1",
+ title: "Issues",
+ pinned: true,
+ },
+ { id: "tB", url: "/acme/projects", title: "Projects", pinned: false },
+ ];
+
+ const { findByText, getByLabelText, queryByText } = render(
+ <TabBar />,
+ locale as Exclude<SupportedLocale, "en">,
+ );
+
+ expect(getByLabelText(copy.newTab)).toBeInTheDocument();
+ expect(getByLabelText(copy.pinned)).toBeInTheDocument();
+ expect(getByLabelText(copy.unpin)).toBeInTheDocument();
+ expect(getByLabelText(copy.pin)).toBeInTheDocument();
+
+ fireEvent.contextMenu(getByLabelText("Projects"));
+ expect(await findByText(copy.pin)).toBeInTheDocument();
+ expect(await findByText(copy.close)).toBeInTheDocument();
+ expect(await findByText(copy.closeOthers)).toBeInTheDocument();
+ expect(queryByText("Pin tab")).toBeNull();
+ expect(queryByText("Close tab")).toBeNull();
+ expect(queryByText("Close other tabs")).toBeNull();
+
+ fireEvent.contextMenu(getByLabelText(copy.pinned));
+ expect(await findByText(copy.unpin)).toBeInTheDocument();
+ expect(await findByText(copy.openWindow)).toBeInTheDocument();
+ expect(queryByText("Unpin tab")).toBeNull();
+ expect(queryByText("Open as new window")).toBeNull();
+ });
+ }
+});
diff --git a/apps/desktop/src/renderer/src/components/tab-bar.tsx b/apps/desktop/src/renderer/src/components/tab-bar.tsx
index 7ab3964cab..bcf8b5a1ee 100644
--- a/apps/desktop/src/renderer/src/components/tab-bar.tsx
+++ b/apps/desktop/src/renderer/src/components/tab-bar.tsx
@@ -38,6 +38,7 @@ import { SIDEBAR_WRAPPER_FILL_CLASS } from "@multica/ui/components/ui/sidebar";
import { cn } from "@multica/ui/lib/utils";
import { useTabStore, useActiveGroup, type Tab } from "@/stores/tab-store";
import { paths } from "@multica/core/paths";
+import { useT } from "@multica/views/i18n";
import {
useTabPresentation,
ResourceLeadingVisual,
@@ -181,6 +182,7 @@ function SortableTabItem({
*/
showSeparator: boolean;
}) {
+ const { t } = useT("settings");
const setActiveTab = useTabStore((s) => s.setActiveTab);
const closeTab = useTabStore((s) => s.closeTab);
const closeOtherTabs = useTabStore((s) => s.closeOtherTabs);
@@ -193,6 +195,15 @@ function SortableTabItem({
// updated as the cache updates. `tab.title` is only a persisted first-frame
// fallback. See @multica/views useTabPresentation.
const { visual, title } = useTabPresentation(tab.url, tab.title);
+ const pinLabel = tab.pinned
+ ? t(($) => $.desktop.tab_bar.unpin)
+ : t(($) => $.desktop.tab_bar.pin);
+ const closeLabel = t(($) => $.desktop.tab_bar.close);
+ const closeOthersLabel = t(($) => $.desktop.tab_bar.close_others);
+ const openWindowLabel = t(($) => $.desktop.tab_bar.open_window);
+ const tabName = tab.pinned
+ ? t(($) => $.desktop.tab_bar.pinned_name, { title })
+ : title;
// Persist the active tab's resolved title so it survives as the next
// session's first-frame fallback. The tab strip itself always renders the
@@ -279,10 +290,10 @@ function SortableTabItem({
e.preventDefault();
handleClose(e);
}}
- aria-label={tab.pinned ? `${title} (pinned)` : title}
+ aria-label={tabName}
data-tab-active={isActive ? "true" : undefined}
data-tab-entering={isEntering ? "true" : undefined}
- title={tab.pinned ? `${title} (pinned)` : undefined}
+ title={tab.pinned ? tabName : undefined}
style={{ WebkitAppRegion: "no-drag" } as React.CSSProperties}
className={cn(
// The 36px frame contains a centered 32px content row and a 4px
@@ -310,8 +321,8 @@ function SortableTabItem({
onClick={handleTogglePin}
onPointerDown={stopDragOnAction}
role="button"
- aria-label={tab.pinned ? "Unpin tab" : "Pin tab"}
- title={tab.pinned ? "Unpin tab" : "Pin tab"}
+ aria-label={pinLabel}
+ title={pinLabel}
className="hidden size-3.5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors group-hover:flex hover:bg-muted-foreground/20 hover:text-foreground"
>
{tab.pinned ? <PinOff className="size-2.5" /> : <Pin className="size-2.5" />}
@@ -321,7 +332,7 @@ function SortableTabItem({
onClick={handleClose}
onPointerDown={stopDragOnAction}
role="button"
- aria-label="Close tab"
+ aria-label={closeLabel}
className="hidden size-3.5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors group-hover:flex hover:bg-muted-foreground/20 hover:text-foreground"
>
<X className="size-2.5" />
@@ -392,7 +403,7 @@ function SortableTabItem({
<>
<ContextMenuItem onClick={handleOpenAsWindow}>
<AppWindow />
- Open as new window
+ {openWindowLabel}
</ContextMenuItem>
<ContextMenuSeparator />
</>
@@ -401,12 +412,12 @@ function SortableTabItem({
{tab.pinned ? (
<>
<PinOff />
- Unpin tab
+ {pinLabel}
</>
) : (
<>
<Pin />
- Pin tab
+ {pinLabel}
</>
)}
</ContextMenuItem>
@@ -417,7 +428,7 @@ function SortableTabItem({
onClick={() => closeTab(tab.id)}
>
<X />
- Close tab
+ {closeLabel}
</ContextMenuItem>
<ContextMenuItem
variant="destructive"
@@ -425,7 +436,7 @@ function SortableTabItem({
onClick={() => closeOtherTabs(tab.id)}
>
<ListX />
- Close other tabs
+ {closeOthersLabel}
</ContextMenuItem>
</ContextMenuContent>
</ContextMenu>
@@ -508,8 +519,10 @@ function NewTabEdgeFeedback({
}
function NewTabButton() {
+ const { t } = useT("settings");
const addTab = useTabStore((s) => s.addTab);
const setActiveTab = useTabStore((s) => s.setActiveTab);
+ const newTabLabel = t(($) => $.desktop.tab_bar.new);
const handleClick = () => {
// New tab opens in the currently active workspace — tabs are scoped
@@ -525,8 +538,8 @@ function NewTabButton() {
<button
type="button"
onClick={handleClick}
- aria-label="New tab"
- title="New tab"
+ aria-label={newTabLabel}
+ title={newTabLabel}
style={{ WebkitAppRegion: "no-drag" } as React.CSSProperties}
className="flex size-7 shrink-0 items-center justify-center self-center rounded-md text-faint-foreground transition-colors hover:bg-muted/50 hover:text-muted-foreground"
>
diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.json
index 5306fa30c4..b69339f8e4 100644
--- a/packages/views/locales/en/settings.json
+++ b/packages/views/locales/en/settings.json
@@ -1226,6 +1226,15 @@
"tabs": {
"updates": "Updates"
},
+ "tab_bar": {
+ "pin": "Pin tab",
+ "unpin": "Unpin tab",
+ "close": "Close tab",
+ "close_others": "Close other tabs",
+ "open_window": "Open as new window",
+ "new": "New tab",
+ "pinned_name": "{{title}} (pinned)"
+ },
"updates": {
"title": "Updates",
"current_version": "Current version",
diff --git a/packages/views/locales/fr/settings.json b/packages/views/locales/fr/settings.json
index 0f2106dbc3..4bdea2ec86 100644
--- a/packages/views/locales/fr/settings.json
+++ b/packages/views/locales/fr/settings.json
@@ -1226,6 +1226,15 @@
"tabs": {
"updates": "Mises à jour"
},
+ "tab_bar": {
+ "pin": "Épingler l'onglet",
+ "unpin": "Désépingler l'onglet",
+ "close": "Fermer l'onglet",
+ "close_others": "Fermer les autres onglets",
+ "open_window": "Ouvrir dans une nouvelle fenêtre",
+ "new": "Nouvel onglet",
+ "pinned_name": "{{title}} (épinglé)"
+ },
"updates": {
"title": "Mises à jour",
"current_version": "Version actuelle",
diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.json
index 0541294745..8a9eed0f13 100644
--- a/packages/views/locales/ja/settings.json
+++ b/packages/views/locales/ja/settings.json
@@ -1220,6 +1220,15 @@
"tabs": {
"updates": "アップデート"
},
+ "tab_bar": {
+ "pin": "タブをピン留め",
+ "unpin": "タブのピン留めを解除",
+ "close": "タブを閉じる",
+ "close_others": "他のタブを閉じる",
+ "open_window": "新しいウィンドウで開く",
+ "new": "新しいタブ",
+ "pinned_name": "{{title}}(ピン留め)"
+ },
"updates": {
"title": "アップデート",
"current_version": "現在のバージョン",
diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.json
index d60336406a..ea6bbd415c 100644
--- a/packages/views/locales/ko/settings.json
+++ b/packages/views/locales/ko/settings.json
@@ -960,6 +960,15 @@
"tabs": {
"updates": "업데이트"
},
+ "tab_bar": {
+ "pin": "탭 고정",
+ "unpin": "탭 고정 해제",
+ "close": "탭 닫기",
+ "close_others": "다른 탭 닫기",
+ "open_window": "새 창에서 열기",
+ "new": "새 탭",
+ "pinned_name": "{{title}} (고정됨)"
+ },
"updates": {
"title": "업데이트",
"current_version": "현재 버전",
diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.json
index a3624d4ed0..4db9b0fb0d 100644
--- a/packages/views/locales/zh-Hans/settings.json
+++ b/packages/views/locales/zh-Hans/settings.json
@@ -1220,6 +1220,15 @@
"tabs": {
"updates": "更新"
},
+ "tab_bar": {
+ "pin": "固定标签页",
+ "unpin": "取消固定标签页",
+ "close": "关闭标签页",
+ "close_others": "关闭其他标签页",
+ "open_window": "在新窗口打开",
+ "new": "新建标签页",
+ "pinned_name": "{{title}}(已固定)"
+ },
"updates": {
"title": "更新",
"current_version": "当前版本",