Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

feat(web): translate the Room Files panel

Kilyn32cc47d5aead
diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/file-library-panel-tab.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/file-library-panel-tab.tsx
index d2265f33..66a8f09a 100644
--- a/apps/web/src/features/rooms/task-sidebar/adapters/file-library-panel-tab.tsx
+++ b/apps/web/src/features/rooms/task-sidebar/adapters/file-library-panel-tab.tsx
@@ -4,9 +4,13 @@ import {
File01Icon,
FolderOpenIcon,
} from "@hugeicons/core-free-icons";
-import { dateTimeFormat } from "@/lib/date-format";
import { useMemo, useState } from "react";
+import { formatLocale } from "@/i18n/language";
+import type { Message } from "@/i18n/messages";
+import { useT } from "@/i18n/use-translation";
+import { dateTimeFormat } from "@/lib/date-format";
+
import { ActionMenu } from "@/components/ui/action-menu";
import { Icon } from "@/components/ui/icon";
import { documentDetailPath } from "@/features/rooms/files/document-detail-routes";
@@ -20,6 +24,7 @@ import { useTeamHubRuntime } from "@/features/teamhub/teamhub-runtime";
import type { TeamHubDocument } from "@/features/teamhub/teamhub-types";
import { PanelCollectionChrome } from "../panel-collection-chrome";
+import { roomDocumentsMessages as m } from "./room-documents.messages";
function copyDocumentLink(document: TeamHubDocument) {
const filename = documentFileName(document);
@@ -47,9 +52,10 @@ export function FileLibraryPanelTab({
hidden?: boolean;
onOpenDocument: (document: TeamHubDocument) => void;
}) {
+ const t = useT();
const { client } = useTeamHubRuntime();
const [busyDocumentId, setBusyDocumentId] = useState<string | null>(null);
- const [actionError, setActionError] = useState<string | null>(null);
+ const [actionError, setActionError] = useState<Message<string> | null>(null);
// Newest first, matching the Library recency view; the name breaks ties so
// documents sharing a timestamp keep a stable order.
const rows = useMemo(
@@ -65,7 +71,7 @@ export function FileLibraryPanelTab({
async function runDocumentAction(
document: TeamHubDocument,
action: () => Promise<void>,
- message: string,
+ message: Message<string>,
) {
if (busyDocumentId !== null) return;
setBusyDocumentId(document.id);
@@ -100,18 +106,18 @@ export function FileLibraryPanelTab({
icon={FolderOpenIcon}
subtitle={
rows.length === 0
- ? "This Room has no documents yet"
- : `${rows.length} ${rows.length === 1 ? "file" : "files"}`
+ ? t(m.noDocumentsYet)
+ : t(m.fileCount, { count: rows.length })
}
- title="Files"
+ title={t(m.title)}
/>
<nav
- aria-label="Room files"
+ aria-label={t(m.roomFiles)}
className="room-file-library workspace-scrollbar min-h-0 flex-1 overflow-y-auto bg-app-surface px-1.5 py-2"
>
{actionError ? (
<p className="px-2 py-1 text-xs text-app-danger" role="alert">
- {actionError}
+ {t(actionError)}
</p>
) : null}
{rows.length ? (
@@ -124,7 +130,7 @@ export function FileLibraryPanelTab({
aria-label={filename}
className="workspace-file-name min-w-0 text-left text-app-body"
onClick={() => onOpenDocument(document)}
- title={`Open ${filename}`}
+ title={t(m.openFile, { name: filename })}
type="button"
>
<WorkspaceFileIcon className="shrink-0" filename={filename} />
@@ -134,17 +140,17 @@ export function FileLibraryPanelTab({
</button>
<RoomFileMetadata document={document} />
<button
- aria-label={`Download ${filename}`}
+ aria-label={t(m.downloadFile, { name: filename })}
className="workspace-file-action"
disabled={!document.capabilities.export || busy}
onClick={() =>
void runDocumentAction(
document,
() => downloadDocument(document),
- "The file could not be downloaded.",
+ m.downloadFailed,
)
}
- title={`Download ${filename}`}
+ title={t(m.downloadFile, { name: filename })}
type="button"
>
<Icon icon={Download01Icon} size={16} />
@@ -155,16 +161,16 @@ export function FileLibraryPanelTab({
{
disabled: busy,
icon: <Icon icon={Copy01Icon} size={14} />,
- label: "Copy link",
+ label: t(m.copyLink),
onSelect: () =>
void runDocumentAction(
document,
() => copyDocumentLink(document),
- "The file link could not be copied.",
+ m.copyLinkFailed,
),
},
]}
- label={`Actions for ${filename}`}
+ label={t(m.actionsFor, { name: filename })}
/>
</div>
);
@@ -173,10 +179,10 @@ export function FileLibraryPanelTab({
<div className="flex h-full min-h-40 flex-col items-center justify-center px-4 text-center">
<Icon className="text-app-subtle" icon={File01Icon} size={20} />
<p className="mt-2 text-sm font-medium text-app-ink">
- No Room Documents yet
+ {t(m.emptyTitle)}
</p>
<p className="mt-1 max-w-52 text-xs leading-5 text-app-muted">
- Documents shared in this Room will show up here.
+ {t(m.emptyBody)}
</p>
</div>
)}
@@ -185,13 +191,9 @@ export function FileLibraryPanelTab({
);
}
-const documentDateFormatter = dateTimeFormat({
- day: "numeric",
- month: "short",
- year: "numeric",
-});
-
function RoomFileMetadata({ document }: { document: TeamHubDocument }) {
+ // Read the language on screen so the date follows a switch.
+ useT();
const owner = document.owner;
const date = new Date(document.updated_at);
return (
@@ -212,7 +214,10 @@ function RoomFileMetadata({ document }: { document: TeamHubDocument }) {
<time dateTime={document.updated_at} title={document.updated_at}>
{Number.isNaN(date.valueOf())
? "—"
- : documentDateFormatter.format(date)}
+ : dateTimeFormat(
+ { day: "numeric", month: "short", year: "numeric" },
+ formatLocale(),
+ ).format(date)}
</time>
</div>
);
diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/file-panel-tab.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/file-panel-tab.tsx
index b429cfaf..c6510f31 100644
--- a/apps/web/src/features/rooms/task-sidebar/adapters/file-panel-tab.tsx
+++ b/apps/web/src/features/rooms/task-sidebar/adapters/file-panel-tab.tsx
@@ -1,6 +1,8 @@
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { lazy, Suspense, useRef, type ComponentProps } from "react";
+import { commonMessages } from "@/i18n/common.messages";
+import { useT } from "@/i18n/use-translation";
import { useTeamHubRuntime } from "@/features/teamhub/teamhub-runtime";
import { Button } from "@/components/ui/button";
import { ArtifactPreviewSurface } from "@/features/rooms/files/artifact-preview-surface";
@@ -11,10 +13,12 @@ import type {
import { TeamHubError } from "@/features/teamhub/teamhub-client";
import { documentQueryOptions } from "../../room-queries";
import { PanelLoading } from "../panel-loading";
+import { sidePanelMessages } from "../side-panel.messages";
import { documentDetailPath } from "../../files/document-detail-routes";
import { documentCardVersionQueryKey } from "../../files/use-document-card-metadata";
import { DocumentVoiceSelectionControl } from "../../documents/document-voice-selection-control";
+import { roomDocumentsMessages as m } from "./room-documents.messages";
const LazyUnifiedDocumentSidebar = lazy(() =>
import("../../documents/room-document-surface").then((module) => ({
@@ -24,8 +28,9 @@ const LazyUnifiedDocumentSidebar = lazy(() =>
function UnifiedDocumentSidebar(
props: ComponentProps<typeof LazyUnifiedDocumentSidebar>,
) {
+ const t = useT();
return (
- <Suspense fallback={<div role="status">Opening document...</div>}>
+ <Suspense fallback={<div role="status">{t(m.openingDocument)}</div>}>
<LazyUnifiedDocumentSidebar {...props} />
</Suspense>
);
@@ -66,6 +71,7 @@ function ConnectedVersionPanelTab({
versionId?: string;
previewCurrentVersion?: boolean;
}) {
+ const t = useT();
const { client } = useTeamHubRuntime();
const queryClient = useQueryClient();
const query = useQuery({
@@ -73,7 +79,8 @@ function ConnectedVersionPanelTab({
enabled: !hidden,
retry: false,
});
- if (query.isPending) return <PanelLoading label="Loading file" />;
+ if (query.isPending)
+ return <PanelLoading label={t(sidePanelMessages.loadingFile)} />;
const unavailable =
(query.error instanceof TeamHubError &&
[403, 404].includes(query.error.status)) ||
@@ -85,18 +92,14 @@ function ConnectedVersionPanelTab({
role="alert"
>
<h3 className="text-sm font-semibold">
- {unavailable
- ? "This file is no longer available"
- : "File could not be loaded"}
+ {unavailable ? t(m.unavailableTitle) : t(m.loadFailedTitle)}
</h3>
<p className="text-xs text-app-muted">
- {unavailable
- ? "The file was removed or you no longer have access."
- : "Please retry loading this file."}
+ {unavailable ? t(m.unavailableBody) : t(m.loadFailedBody)}
</p>
{!unavailable ? (
<Button onClick={() => void query.refetch()} size="compact">
- Retry
+ {t(commonMessages.retry)}
</Button>
) : null}
</div>
diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/room-documents-language.test.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/room-documents-language.test.tsx
new file mode 100644
index 00000000..670514d0
--- /dev/null
+++ b/apps/web/src/features/rooms/task-sidebar/adapters/room-documents-language.test.tsx
@@ -0,0 +1,80 @@
+// @vitest-environment jsdom
+import { act, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it } from "vitest";
+
+import { documentFileName } from "@/features/library/document-display-name";
+import { TeamHubRuntimeProvider } from "@/features/teamhub/teamhub-runtime";
+import { resetLanguageForTest, setLanguage } from "@/i18n/language";
+import zhCN from "@/i18n/locales/zh-CN.json";
+import {
+ createDocumentTestRuntime,
+ seedRoomDocument,
+} from "@/test/document-scenarios";
+
+import { FileLibraryPanelTab } from "./file-library-panel-tab";
+
+const words = zhCN.roomDocuments;
+
+describe("Room Files tab in the language on screen", () => {
+ afterEach(() => resetLanguageForTest());
+
+ it("words the list, its actions and the date", async () => {
+ const runtime = createDocumentTestRuntime();
+ const document = seedRoomDocument(runtime, "room-files-language-1");
+ render(
+ <TeamHubRuntimeProvider runtime={runtime}>
+ <FileLibraryPanelTab documents={[document]} onOpenDocument={() => {}} />
+ </TeamHubRuntimeProvider>,
+ );
+ expect(
+ screen.getByRole("navigation", { name: "Room files" }),
+ ).toBeVisible();
+ expect(screen.getByText("1 file")).toBeVisible();
+ const english = new Intl.DateTimeFormat("en-US", {
+ day: "numeric",
+ month: "short",
+ year: "numeric",
+ }).format(new Date(document.updated_at));
+ expect(screen.getByText(english)).toBeVisible();
+
+ await act(() => setLanguage("zh-CN"));
+ expect(
+ screen.getByRole("navigation", { name: words.roomFiles }),
+ ).toBeVisible();
+ expect(
+ screen.getByText(words.fileCount.other.replace("{count}", "1")),
+ ).toBeVisible();
+ expect(screen.queryByText(english)).toBeNull();
+ expect(
+ screen.getByText(
+ new Intl.DateTimeFormat("zh-CN", {
+ day: "numeric",
+ month: "short",
+ year: "numeric",
+ }).format(new Date(document.updated_at)),
+ ),
+ ).toBeVisible();
+ expect(
+ screen.getByRole("button", {
+ name: words.downloadFile.replace("{name}", documentFileName(document)),
+ }),
+ ).toBeVisible();
+ expect(
+ screen.getByRole("button", {
+ name: words.actionsFor.replace("{name}", documentFileName(document)),
+ }),
+ ).toBeVisible();
+ });
+
+ it("words the empty list", async () => {
+ await setLanguage("zh-CN");
+ render(
+ <TeamHubRuntimeProvider runtime={createDocumentTestRuntime()}>
+ <FileLibraryPanelTab documents={[]} onOpenDocument={() => {}} />
+ </TeamHubRuntimeProvider>,
+ );
+ expect(screen.getByText(words.noDocumentsYet)).toBeVisible();
+ expect(screen.getByText(words.emptyTitle)).toBeVisible();
+ expect(screen.getByText(words.emptyBody)).toBeVisible();
+ });
+});
diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/room-documents.messages.ts b/apps/web/src/features/rooms/task-sidebar/adapters/room-documents.messages.ts
new file mode 100644
index 00000000..8227ff4c
--- /dev/null
+++ b/apps/web/src/features/rooms/task-sidebar/adapters/room-documents.messages.ts
@@ -0,0 +1,25 @@
+import { defineMessages } from "@/i18n/messages";
+
+/**
+ * The Files tab of the Room side panel: the list of the Room's Documents, and
+ * the states around a file tab before its preview or editor takes over.
+ */
+export const roomDocumentsMessages = defineMessages("roomDocuments", {
+ title: "Files",
+ noDocumentsYet: "This Room has no documents yet",
+ fileCount: { one: "{count} file", other: "{count} files" },
+ roomFiles: "Room files",
+ openFile: "Open {name}",
+ downloadFile: "Download {name}",
+ downloadFailed: "The file could not be downloaded.",
+ copyLink: "Copy link",
+ copyLinkFailed: "The file link could not be copied.",
+ actionsFor: "Actions for {name}",
+ emptyTitle: "No Room Documents yet",
+ emptyBody: "Documents shared in this Room will show up here.",
+ openingDocument: "Opening document...",
+ unavailableTitle: "This file is no longer available",
+ unavailableBody: "The file was removed or you no longer have access.",
+ loadFailedTitle: "File could not be loaded",
+ loadFailedBody: "Please retry loading this file.",
+});
diff --git a/apps/web/src/i18n/locales/zh-CN.json b/apps/web/src/i18n/locales/zh-CN.json
index d46d62cb..5f39c650 100644
--- a/apps/web/src/i18n/locales/zh-CN.json
+++ b/apps/web/src/i18n/locales/zh-CN.json
@@ -2650,5 +2650,24 @@
"saveFailed": "无法保存 Routine。",
"deleteFailed": "无法删除 Routine。",
"runFailed": "无法运行 Routine。"
+ },
+ "roomDocuments": {
+ "title": "文件",
+ "noDocumentsYet": "这个 Room 还没有文档",
+ "fileCount": { "other": "{count} 个文件" },
+ "roomFiles": "Room 文件",
+ "openFile": "打开 {name}",
+ "downloadFile": "下载 {name}",
+ "downloadFailed": "无法下载这个文件。",
+ "copyLink": "复制链接",
+ "copyLinkFailed": "无法复制文件链接。",
+ "actionsFor": "{name} 的操作",
+ "emptyTitle": "还没有 Room 文档",
+ "emptyBody": "在这个 Room 中共享的文档会显示在这里。",
+ "openingDocument": "正在打开文档…",
+ "unavailableTitle": "这个文件已不可用",
+ "unavailableBody": "文件已被移除,或者你已失去访问权限。",
+ "loadFailedTitle": "无法加载文件",
+ "loadFailedBody": "请重试加载这个文件。"
}
}