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 document page, sharing and comments

Kilynff17926d5079
diff --git a/apps/web/src/components/knowledge-reading-extension.ts b/apps/web/src/components/knowledge-reading-extension.ts
index e9714ebc..51521153 100644
--- a/apps/web/src/components/knowledge-reading-extension.ts
+++ b/apps/web/src/components/knowledge-reading-extension.ts
@@ -3,6 +3,9 @@ import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
import { Plugin, PluginKey } from "@tiptap/pm/state";
import { Decoration, DecorationSet, type EditorView } from "@tiptap/pm/view";
+import { documentEditorMessages } from "@/features/rooms/documents/document-editor.messages";
+import { translate } from "@/i18n/language";
+
import {
isKnowledgeChangeLogHeading,
isKnowledgeHistoryHeading,
@@ -176,7 +179,11 @@ function sectionToggle(view: EditorView, expanded: boolean) {
wrapper.contentEditable = "false";
const button = document.createElement("button");
button.type = "button";
- button.textContent = expanded ? "Show less" : "View more";
+ button.textContent = translate(
+ expanded
+ ? documentEditorMessages.showLess
+ : documentEditorMessages.viewMore,
+ );
button.setAttribute("aria-expanded", String(expanded));
button.addEventListener("mousedown", (event) => event.preventDefault());
button.addEventListener("click", (event) => {
diff --git a/apps/web/src/components/read-only-blocknote-document-loader.tsx b/apps/web/src/components/read-only-blocknote-document-loader.tsx
index 858dadfa..58fb55b3 100644
--- a/apps/web/src/components/read-only-blocknote-document-loader.tsx
+++ b/apps/web/src/components/read-only-blocknote-document-loader.tsx
@@ -1,4 +1,8 @@
import { lazy, Suspense } from "react";
+
+import { documentEditorMessages } from "@/features/rooms/documents/document-editor.messages";
+import { useT } from "@/i18n/use-translation";
+
import { Spinner } from "./ui/spinner";
import type { ReadOnlyBlockNoteDocumentProps } from "./read-only-blocknote-document";
@@ -11,6 +15,7 @@ const ReadOnlyBlockNoteDocument = lazy(() =>
export function ReadOnlyBlockNoteDocumentLoader(
props: ReadOnlyBlockNoteDocumentProps,
) {
+ const t = useT();
return (
<Suspense
fallback={
@@ -19,7 +24,7 @@ export function ReadOnlyBlockNoteDocumentLoader(
role="status"
>
<Spinner size={16} />
- Loading document…
+ {t(documentEditorMessages.loadingDocument)}
</div>
}
>
diff --git a/apps/web/src/components/read-only-blocknote-document.tsx b/apps/web/src/components/read-only-blocknote-document.tsx
index b3fffec6..bb7a1b36 100644
--- a/apps/web/src/components/read-only-blocknote-document.tsx
+++ b/apps/web/src/components/read-only-blocknote-document.tsx
@@ -13,7 +13,9 @@ import { BlockNoteView } from "@blocknote/mantine";
import { useCreateBlockNote } from "@blocknote/react";
import { useMemo } from "react";
import { createKnowledgeReadingExtension } from "./knowledge-reading-extension";
+import { documentEditorMessages } from "@/features/rooms/documents/document-editor.messages";
import { roomDocumentCodeBlockSpec } from "@/features/rooms/documents/room-document-mermaid-code-block";
+import { useT } from "@/i18n/use-translation";
import {
prepareReadOnlyMarkdown,
@@ -43,10 +45,13 @@ export function ReadOnlyBlockNoteDocument({
hiddenSectionTitles,
resolveLink,
}: ReadOnlyBlockNoteDocumentProps) {
+ const t = useT();
+ const mediaOmitted = t(documentEditorMessages.embeddedMediaOmitted);
const initialContent = useMemo(
() =>
parseSafeMarkdown(
markdown,
+ mediaOmitted,
assetBaseUrl,
presentation,
documentTitle,
@@ -56,6 +61,7 @@ export function ReadOnlyBlockNoteDocument({
[
assetBaseUrl,
markdown,
+ mediaOmitted,
presentation,
documentTitle,
hiddenSectionTitles,
@@ -109,6 +115,7 @@ export function ReadOnlyBlockNoteDocument({
function parseSafeMarkdown(
markdown: string,
+ mediaOmitted: string,
assetBaseUrl?: string,
presentation: ReadOnlyMarkdownPresentation = "default",
documentTitle?: string,
@@ -126,6 +133,7 @@ function parseSafeMarkdown(
hiddenSectionTitles,
),
),
+ mediaOmitted,
assetBaseUrl,
resolveLink,
);
@@ -137,6 +145,8 @@ function parseSafeMarkdown(
function sanitizeEmbeddedContent(
blocks: Block[],
+ /** Shown in place of media the reader cannot load. */
+ mediaOmitted: string,
assetBaseUrl?: string,
resolveLink?: ReadOnlyBlockNoteDocumentProps["resolveLink"],
): PartialBlock[] {
@@ -155,7 +165,7 @@ function sanitizeEmbeddedContent(
};
}
return {
- content: props.caption || props.name || "Embedded media omitted.",
+ content: props.caption || props.name || mediaOmitted,
type: "paragraph",
};
}
@@ -167,7 +177,7 @@ function sanitizeEmbeddedContent(
) {
const props = block.props as { caption?: string; name?: string };
return {
- content: props.caption || props.name || "Embedded media omitted.",
+ content: props.caption || props.name || mediaOmitted,
type: "paragraph",
};
}
@@ -176,6 +186,7 @@ function sanitizeEmbeddedContent(
...block,
children: sanitizeEmbeddedContent(
block.children,
+ mediaOmitted,
assetBaseUrl,
resolveLink,
),
diff --git a/apps/web/src/features/rooms/chat/voice-mode/voice-risk-markers.test.ts b/apps/web/src/features/rooms/chat/voice-mode/voice-risk-markers.test.ts
index 4549d32d..e0298142 100644
--- a/apps/web/src/features/rooms/chat/voice-mode/voice-risk-markers.test.ts
+++ b/apps/web/src/features/rooms/chat/voice-mode/voice-risk-markers.test.ts
@@ -55,6 +55,10 @@ const notActions: Record<string, string> = {
"leaves full screen in place; it decides nothing and closes nothing",
"/src/features/rooms/files/artifact-content-renderer.tsx: filePreview.resetImageZoom":
"resets the image zoom in place; it decides nothing",
+ "/src/features/rooms/documents/document-share-dialog.tsx: documentShare.removeAccess":
+ "the permission option only opens the confirm dialog; its marked Remove access button removes",
+ "/src/features/rooms/documents/room-document-comment-thread.tsx: documentComments.deletedReference":
+ "says the quoted text of a comment was deleted; the button only scrolls to the quote",
};
type Need = "confirm" | "never" | "close";
diff --git a/apps/web/src/features/rooms/documents/document-comments-language.test.tsx b/apps/web/src/features/rooms/documents/document-comments-language.test.tsx
new file mode 100644
index 00000000..9361fb66
--- /dev/null
+++ b/apps/web/src/features/rooms/documents/document-comments-language.test.tsx
@@ -0,0 +1,142 @@
+import type { CommentData } from "@blocknote/core/comments";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { fireEvent, render, screen, within } from "@testing-library/react";
+import { afterEach, describe, expect, it } from "vitest";
+
+import { createHttpTeamHubClient } from "@/features/teamhub/teamhub-client";
+import type { TeamHubActorRef } from "@/features/teamhub/teamhub-types";
+import { resetLanguageForTest, setLanguage } from "@/i18n/language";
+import zhCN from "@/i18n/locales/zh-CN.json";
+import { formatDateTime } from "@/lib/date-format";
+import { TeamHubTestServer } from "@/test/teamhub-test-server";
+
+import { commentThreadResponse } from "./document-comment-test-data";
+import { DocumentCommentsPanel } from "./document-comments-panel";
+import { commentBodyFromComposition } from "./room-document-comment-body";
+import { RoomDocumentCommentRow } from "./room-document-comment-row";
+import type { TeamHubDocumentThreadStore } from "./room-document-comments";
+
+const comments = zhCN.documentComments;
+
+describe("Document comments in the language on screen", () => {
+ afterEach(() => {
+ resetLanguageForTest();
+ });
+
+ it("words the comments panel in Chinese and marks close and send", async () => {
+ await setLanguage("zh-CN");
+ const thread = commentThreadResponse("thread_language", "Review text");
+ const server = new TeamHubTestServer().on(
+ "GET",
+ "/v0/documents/{documentId}/comment-threads",
+ () => ({ items: [thread], page: { has_more: false } }),
+ );
+ const client = createHttpTeamHubClient({
+ fetchRequest: server.fetch,
+ onAuthenticationRequired: () => undefined,
+ });
+
+ render(
+ <QueryClientProvider
+ client={
+ new QueryClient({ defaultOptions: { queries: { retry: false } } })
+ }
+ >
+ <DocumentCommentsPanel
+ client={client}
+ documentId="document_1"
+ documentVersionId="version_1"
+ onClose={() => undefined}
+ open
+ portalTarget={document.body}
+ roomId="room_1"
+ scopeId="room_1"
+ tenantId="tenant_1"
+ />
+ </QueryClientProvider>,
+ );
+
+ expect(await screen.findByText("Review text")).toBeVisible();
+ expect(
+ screen.getByRole("heading", { name: comments.comments }),
+ ).toBeVisible();
+ expect(
+ screen.getByRole("button", { name: comments.closeComments }),
+ ).toHaveAttribute("data-voice-close");
+ expect(screen.getByLabelText(comments.newComment)).toHaveAttribute(
+ "placeholder",
+ comments.addCommentPlaceholder,
+ );
+ expect(
+ screen.getByRole("button", { name: comments.addComment }),
+ ).toBeVisible();
+
+ const threadView = screen.getByLabelText(
+ comments.commentBy.replace("{name}", "Jenny"),
+ );
+ const date = formatDateTime(
+ thread.created_at,
+ { day: "numeric", month: "short" },
+ "zh-CN",
+ );
+ expect(within(threadView).getByText(date)).toBeVisible();
+
+ fireEvent.click(
+ within(threadView).getByRole("button", { name: comments.reply }),
+ );
+ expect(await screen.findByLabelText(comments.replyToComment)).toBeVisible();
+ expect(
+ screen.getByRole("button", { name: comments.sendReply }),
+ ).toHaveAttribute("data-voice-risk", "never");
+ });
+
+ it("words a comment row in Chinese and marks Delete", async () => {
+ await setLanguage("zh-CN");
+ const author: TeamHubActorRef = {
+ display_name: "Reviewer",
+ id: "agent-reviewer",
+ kind: "agent",
+ tenant_id: "tenant_1",
+ };
+ const comment: CommentData = {
+ body: commentBodyFromComposition({
+ body: "Looks good",
+ files: [],
+ mentions: [],
+ }),
+ createdAt: new Date("2026-09-20T00:00:00Z"),
+ id: "comment_1",
+ metadata: { author },
+ reactions: [],
+ type: "comment",
+ updatedAt: new Date("2026-09-20T00:00:00Z"),
+ userId: author.id,
+ };
+ const threadStore = {
+ auth: {
+ canAddReaction: () => false,
+ canDeleteComment: () => true,
+ canDeleteReaction: () => false,
+ canUpdateComment: () => true,
+ },
+ } as unknown as TeamHubDocumentThreadStore;
+
+ render(
+ <RoomDocumentCommentRow
+ actors={new Map([[author.id, author]])}
+ comment={comment}
+ mentionOptions={[]}
+ threadId="thread_1"
+ threadStore={threadStore}
+ />,
+ );
+
+ expect(screen.getByText("Looks good")).toBeVisible();
+ expect(
+ screen.getByRole("button", { name: comments.editComment }),
+ ).toBeVisible();
+ expect(
+ screen.getByRole("button", { name: comments.deleteComment }),
+ ).toHaveAttribute("data-voice-risk", "never");
+ });
+});
diff --git a/apps/web/src/features/rooms/documents/document-comments-panel.tsx b/apps/web/src/features/rooms/documents/document-comments-panel.tsx
index 236a808e..4f40b0ff 100644
--- a/apps/web/src/features/rooms/documents/document-comments-panel.tsx
+++ b/apps/web/src/features/rooms/documents/document-comments-panel.tsx
@@ -17,7 +17,11 @@ import { ActorAvatar } from "@/features/rooms/members/actor-avatar";
import { teamHubData } from "@/features/teamhub/teamhub-api";
import type { TeamHubClient } from "@/features/teamhub/teamhub-client";
import type { TeamHubDocumentCommentThread } from "@/features/teamhub/teamhub-types";
+import { commonMessages } from "@/i18n/common.messages";
+import { formatLocale, translate } from "@/i18n/language";
+import { useT, useTranslation } from "@/i18n/use-translation";
+import { documentCommentsMessages as m } from "./document-comments.messages";
import { roomDocumentCommentThreadsQueryOptions } from "./room-document-comments";
export function DocumentCommentsPanel({
@@ -45,6 +49,7 @@ export function DocumentCommentsPanel({
selectionQuote?: string | null;
tenantId: string;
}) {
+ const t = useT();
const queryClient = useQueryClient();
const threadOptions = roomDocumentCommentThreadsQueryOptions(
client,
@@ -137,16 +142,17 @@ export function DocumentCommentsPanel({
return createPortal(
<aside
- aria-label="All Document comments"
+ aria-label={t(m.allComments)}
className="flex h-full min-h-0 flex-col bg-app-surface"
>
<div className="flex shrink-0 items-center justify-between px-3 pb-2 pt-5">
- <h3 className="text-sm font-semibold text-app-ink">Comments</h3>
+ <h3 className="text-sm font-semibold text-app-ink">{t(m.comments)}</h3>
<Button
- aria-label="Close comments"
+ aria-label={t(m.closeComments)}
+ data-voice-close
onClick={onClose}
size="compactIcon"
- title="Close comments"
+ title={t(m.closeComments)}
tone="ghost"
>
<Icon icon={Cancel01Icon} size={14} />
@@ -155,13 +161,11 @@ export function DocumentCommentsPanel({
<div className="workspace-scrollbar min-h-0 flex-1 overflow-y-auto">
{threads.isPending ? (
<p className="px-4 py-8 text-center text-sm text-app-muted">
- Loading comments...
+ {t(m.loadingComments)}
</p>
) : threads.isError ? (
<div className="px-4 py-8 text-center" role="alert">
- <p className="text-sm text-app-danger">
- Comments could not be loaded.
- </p>
+ <p className="text-sm text-app-danger">{t(m.loadFailed)}</p>
<Button
className="mt-3"
onClick={() => void threads.refetch()}
@@ -169,12 +173,12 @@ export function DocumentCommentsPanel({
tone="secondary"
>
<Icon icon={RotateLeft01Icon} size={14} />
- Retry
+ {t(commonMessages.retry)}
</Button>
</div>
) : items.length === 0 ? (
<p className="px-4 py-8 text-center text-sm text-app-muted">
- No comments
+ {t(m.noComments)}
</p>
) : (
<div className="space-y-3 p-3">
@@ -190,10 +194,10 @@ export function DocumentCommentsPanel({
</div>
{documentVersionId && threads.isSuccess ? (
<DocumentCommentComposer
- actionLabel="Add comment"
- ariaLabel="New Document comment"
+ actionLabel={t(m.addComment)}
+ ariaLabel={t(m.newComment)}
onSubmit={createThread}
- placeholder="Add comment..."
+ placeholder={t(m.addCommentPlaceholder)}
selectionQuote={selectionQuote}
/>
) : null}
@@ -209,6 +213,7 @@ function DocumentCommentComposer({
onSubmit,
placeholder,
selectionQuote,
+ voiceRisk,
}: {
actionLabel: string;
ariaLabel: string;
@@ -216,7 +221,9 @@ function DocumentCommentComposer({
onSubmit: (body: string) => Promise<void>;
placeholder: string;
selectionQuote?: string | null;
+ voiceRisk?: "confirm" | "never";
}) {
+ const t = useT();
const [body, setBody] = useState("");
const [error, setError] = useState<string | null>(null);
const [pending, setPending] = useState(false);
@@ -233,9 +240,7 @@ function DocumentCommentComposer({
await onSubmit(content);
setBody("");
} catch (cause) {
- setError(
- cause instanceof Error ? cause.message : "Comment could not be added.",
- );
+ setError(cause instanceof Error ? cause.message : translate(m.addFailed));
} finally {
setPending(false);
}
@@ -291,13 +296,14 @@ function DocumentCommentComposer({
<Button
aria-label={actionLabel}
className="document-comment-send !rounded-full"
+ data-voice-risk={voiceRisk}
disabled={!body.trim() || pending}
size="compactIcon"
tone="primary"
type="submit"
>
<Icon icon={ArrowUp02Icon} size={14} />
- <span className="sr-only">{pending ? "Adding..." : actionLabel}</span>
+ <span className="sr-only">{pending ? t(m.adding) : actionLabel}</span>
</Button>
</div>
{error ? (
@@ -316,6 +322,7 @@ function DocumentCommentThread({
onReply: (body: string) => Promise<void>;
thread: TeamHubDocumentCommentThread;
}) {
+ const { language, t } = useTranslation();
const [replying, setReplying] = useState(false);
const firstComment = thread.comments[0];
const firstBody =
@@ -326,7 +333,7 @@ function DocumentCommentThread({
: null;
return (
<article
- aria-label={`Comment by ${thread.created_by.display_name}`}
+ aria-label={t(m.commentBy, { name: thread.created_by.display_name })}
className="rounded-xl border border-app-border bg-card p-2"
>
{reference ? (
@@ -352,14 +359,15 @@ function DocumentCommentThread({
className="block text-xs leading-4 text-app-subtle"
dateTime={comment.created_at}
>
- {formatDateTime(comment.created_at, {
- day: "numeric",
- month: "short",
- })}
+ {formatDateTime(
+ comment.created_at,
+ { day: "numeric", month: "short" },
+ formatLocale(language),
+ )}
</time>
<div className="mt-2 min-w-0 text-sm leading-5 text-app-body">
{comment.deleted_at ? (
- "Comment deleted"
+ t(m.commentDeleted)
) : (
<MessageMarkdown
authorKind={comment.author.kind}
@@ -381,24 +389,25 @@ function DocumentCommentThread({
<div className="mt-2">
{replying ? (
<DocumentCommentComposer
- actionLabel="Send reply"
- ariaLabel="Reply to Document comment"
+ actionLabel={t(m.sendReply)}
+ ariaLabel={t(m.replyToComment)}
embedded
onSubmit={async (body) => {
await onReply(body);
setReplying(false);
}}
- placeholder="Add comment..."
+ placeholder={t(m.addCommentPlaceholder)}
+ voiceRisk="never"
/>
) : (
<Button
- aria-label="Reply"
+ aria-label={t(m.reply)}
onClick={() => setReplying(true)}
size="compact"
tone="ghost"
>
<Icon icon={ArrowTurnBackwardIcon} size={14} />
- Reply
+ {t(m.reply)}
</Button>
)}
</div>
diff --git a/apps/web/src/features/rooms/documents/document-comments.messages.ts b/apps/web/src/features/rooms/documents/document-comments.messages.ts
new file mode 100644
index 00000000..371d88a5
--- /dev/null
+++ b/apps/web/src/features/rooms/documents/document-comments.messages.ts
@@ -0,0 +1,55 @@
+import { defineMessages } from "@/i18n/messages";
+
+/**
+ * Document comments: the comments panel beside a Document, its threads,
+ * rows and composers. Comment text, quoted Document text and author names
+ * are data and are shown as they arrive.
+ */
+export const documentCommentsMessages = defineMessages("documentComments", {
+ allComments: "All Document comments",
+ comments: "Comments",
+ closeComments: "Close comments",
+ loadingComments: "Loading comments...",
+ loadFailed: "Comments could not be loaded.",
+ noComments: "No comments",
+ addComment: "Add comment",
+ newComment: "New Document comment",
+ addCommentPlaceholder: "Add comment...",
+ addFailed: "Comment could not be added.",
+ adding: "Adding...",
+ commentBy: "Comment by {name}",
+ commentDeleted: "Comment deleted",
+ sendReply: "Send reply",
+ replyToComment: "Reply to Document comment",
+ reply: "Reply",
+ // {count} is the number of comment threads in the Document.
+ showAllComments: "Show all Document comments ({count})",
+ selectedText: "Selected text",
+ noResolvedComments: "No resolved comments",
+ noOpenComments: "No open comments",
+ selectTextHint: "Select text in the document, then choose Add comment.",
+ deletedReference: "Deleted reference",
+ // {reference} is the Document text the comment is attached to.
+ commentOn: "Comment on {reference}",
+ linkFailed: "Comment saved, but it couldn't be linked to the selected text.",
+ retrying: "Retrying...",
+ retryLinking: "Retry linking",
+ unknownAuthor: "Unknown author",
+ actionFailed: "Comment action failed",
+ editCommentBy: "Edit comment by {name}",
+ editComment: "Edit comment",
+ confirm: "Confirm",
+ deleteComment: "Delete comment",
+ addCommentPlaceholderShort: "Add a comment",
+ replyPlaceholder: "Reply...",
+ mentionDirectoryUnavailable: "Mention directory is unavailable.",
+ agentReplying: "{name} is replying",
+ // {names} is a list of Agent names joined with listSeparator; {last} is
+ // the last Agent.
+ agentsReplying: "{names} and {last} are replying",
+ // Joins names in a list.
+ listSeparator: ", ",
+ addCommentToSelection: "Add comment to selected text",
+ saveBeforeCommenting: "Save the Document before creating or editing Comments",
+ newSelectionComment: "New selection comment",
+});
diff --git a/apps/web/src/features/rooms/documents/document-editor.messages.ts b/apps/web/src/features/rooms/documents/document-editor.messages.ts
new file mode 100644
index 00000000..856d2f88
--- /dev/null
+++ b/apps/web/src/features/rooms/documents/document-editor.messages.ts
@@ -0,0 +1,43 @@
+import { defineMessages } from "@/i18n/messages";
+
+/**
+ * The Document editor chrome around BlockNote: the editor region, the file
+ * panel, the slash menu's Mermaid item, image upload status and the Mermaid
+ * code block toolbar. BlockNote's own menus use its bundled dictionary.
+ * File names, code and Mermaid error details are data.
+ */
+export const documentEditorMessages = defineMessages("documentEditor", {
+ editor: "Room Document editor",
+ loadingEditor: "Loading Room Document editor",
+ blockUpdateFailed:
+ "The file was uploaded, but the Document block could not be updated. Try inserting it again.",
+ uploadFailed: "Document Asset upload failed.",
+ assetSizeUnsupported: "Document Asset size is outside the supported range.",
+ assetChangedWhileReading: "Document Asset changed while it was being read.",
+ upload: "Upload",
+ chooseFile: "Choose a file",
+ // The slash menu group of the Mermaid item; BlockNote's own group for
+ // other blocks is the same word in Chinese, so the two groups merge.
+ slashGroupOther: "Other",
+ mermaidSubtext: "Create an editable Mermaid diagram",
+ mermaidTitle: "Mermaid diagram",
+ uploadingFile: "Uploading {filename}",
+ loadingFile: "Loading {filename}",
+ fileUnavailable: "{filename} is unavailable",
+ // The name of a pasted image that has no file name.
+ image: "image",
+ source: "Source",
+ preview: "Preview",
+ copySource: "Copy source",
+ selectSourceToCopy: "Select source to copy",
+ addMermaidSource: "Add Mermaid source to see the diagram.",
+ mermaidSourceUnavailable: "Mermaid source is unavailable.",
+ mermaidPreview: "Mermaid diagram preview",
+ // {message} is the parser's own error text.
+ mermaidSyntaxError: "Mermaid syntax error: {message}",
+ mermaidSyntaxErrorPlain: "Mermaid syntax error.",
+ loadingDocument: "Loading document…",
+ embeddedMediaOmitted: "Embedded media omitted.",
+ showLess: "Show less",
+ viewMore: "View more",
+});
diff --git a/apps/web/src/features/rooms/documents/document-history-revision.ts b/apps/web/src/features/rooms/documents/document-history-revision.ts
index c1745d62..65baecbb 100644
--- a/apps/web/src/features/rooms/documents/document-history-revision.ts
+++ b/apps/web/src/features/rooms/documents/document-history-revision.ts
@@ -4,6 +4,9 @@ import { sha256 } from "@noble/hashes/sha2.js";
import { bytesToHex } from "@noble/hashes/utils.js";
import * as Y from "yjs";
+import { translate } from "@/i18n/language";
+
+import { documentPageMessages as m } from "./document-page.messages";
import { roomDocumentCommentSchema } from "./room-document-comment-schema";
export function historyRevisionMarkdown(
@@ -12,7 +15,7 @@ export function historyRevisionMarkdown(
) {
const stateBytes = decodeBase64(stateBytesBase64);
if (bytesToHex(sha256(stateBytes)) !== expectedSHA256) {
- throw new Error("History Revision bytes failed integrity verification.");
+ throw new Error(translate(m.revisionIntegrityFailed));
}
const document = new Y.Doc({ gc: true });
document.getXmlFragment("prosemirror");
@@ -31,6 +34,6 @@ function decodeBase64(value: string) {
try {
return Uint8Array.from(atob(value), (character) => character.charCodeAt(0));
} catch {
- throw new Error("History Revision bytes are invalid.");
+ throw new Error(translate(m.revisionInvalid));
}
}
diff --git a/apps/web/src/features/rooms/documents/document-link-sharing.tsx b/apps/web/src/features/rooms/documents/document-link-sharing.tsx
index 3860e45c..bae75555 100644
--- a/apps/web/src/features/rooms/documents/document-link-sharing.tsx
+++ b/apps/web/src/features/rooms/documents/document-link-sharing.tsx
@@ -10,6 +10,10 @@ import { Button } from "@/components/ui/button";
import { Select, SelectItem } from "@/components/ui/select";
import type { TeamHubClient } from "@/features/teamhub/teamhub-client";
import { writeClipboardText } from "@/lib/clipboard";
+import { translate } from "@/i18n/language";
+import { useT } from "@/i18n/use-translation";
+
+import { documentShareMessages as m } from "./document-share.messages";
export function DocumentLinkSharing({
client,
@@ -18,6 +22,7 @@ export function DocumentLinkSharing({
client: TeamHubClient;
documentId: string;
}) {
+ const t = useT();
const policy = useQuery({
queryKey: ["teamhub", "document-link-policy", documentId],
queryFn: () => client.documentLinks.get(documentId),
@@ -50,9 +55,7 @@ export function DocumentLinkSharing({
await policy.refetch();
} catch (cause) {
setError(
- cause instanceof Error
- ? cause.message
- : "Link sharing could not be updated.",
+ cause instanceof Error ? cause.message : translate(m.linkUpdateFailed),
);
await policy.refetch();
} finally {
@@ -63,9 +66,9 @@ export function DocumentLinkSharing({
<section className="mt-5 border-t border-app-border pt-4">
<div className="flex flex-wrap items-center gap-3">
<Icon icon={Link01Icon} className="text-app-muted" />
- <h3 className="mr-auto text-sm font-medium">Anyone with the link</h3>
+ <h3 className="mr-auto text-sm font-medium">{t(m.anyoneWithLink)}</h3>
<Select
- aria-label="Link access"
+ aria-label={t(m.linkAccess)}
value={active ? policy.data!.role : "disabled"}
disabled={pending || policy.isPending || Boolean(policy.error)}
onValueChange={(value) =>
@@ -73,14 +76,15 @@ export function DocumentLinkSharing({
}
className="h-8 w-auto"
>
- <SelectItem value="disabled">Disabled</SelectItem>
- <SelectItem value="viewer">Can view</SelectItem>
- <SelectItem value="editor">Can edit</SelectItem>
+ <SelectItem value="disabled">{t(m.linkDisabled)}</SelectItem>
+ <SelectItem value="viewer">{t(m.canView)}</SelectItem>
+ <SelectItem value="editor">{t(m.canEdit)}</SelectItem>
</Select>
{active ? (
<Button
- aria-label="Reset link"
- title="Reset link"
+ aria-label={t(m.resetLink)}
+ data-voice-risk="confirm"
+ title={t(m.resetLink)}
disabled={pending}
size="compactIcon"
tone="ghost"
@@ -91,13 +95,13 @@ export function DocumentLinkSharing({
) : null}
{active && link?.version === policy.data?.version ? (
<Button
- aria-label="Copy shared link"
- title="Copy shared link"
+ aria-label={t(m.copySharedLink)}
+ title={t(m.copySharedLink)}
size="compactIcon"
tone="ghost"
onClick={() =>
void writeClipboardText(link!.url).catch(() =>
- setError("Could not copy the link."),
+ setError(translate(m.sharedLinkCopyFailed)),
)
}
>
@@ -107,7 +111,7 @@ export function DocumentLinkSharing({
</div>
{error || policy.error ? (
<p role="alert" className="mt-2 text-sm text-app-danger">
- {error ?? "Link sharing is unavailable."}
+ {error ?? t(m.linkSharingUnavailable)}
</p>
) : null}
</section>
diff --git a/apps/web/src/features/rooms/documents/document-page-language.test.tsx b/apps/web/src/features/rooms/documents/document-page-language.test.tsx
new file mode 100644
index 00000000..926792ca
--- /dev/null
+++ b/apps/web/src/features/rooms/documents/document-page-language.test.tsx
@@ -0,0 +1,195 @@
+import { materializeRoomDocument } from "@linger/document-model";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { fireEvent, render, screen, within } from "@testing-library/react";
+import { createMemoryRouter, RouterProvider } from "react-router";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import { LibraryLayout } from "@/features/library/library-layout";
+import type {
+ TeamHubDocumentHistoryContent,
+ TeamHubDocumentHistoryEntry,
+} from "@/features/teamhub/teamhub-types";
+import {
+ TeamHubRuntimeProvider,
+ type TeamHubRuntime,
+} from "@/features/teamhub/teamhub-runtime";
+import { resetLanguageForTest, setLanguage } from "@/i18n/language";
+import zhCN from "@/i18n/locales/zh-CN.json";
+import { formatDateTime } from "@/lib/date-format";
+import {
+ createDocumentTestRuntime,
+ seedNativeDocument,
+} from "@/test/document-scenarios";
+import { createTestTeamHubRuntime } from "@/test/teamhub-test-runtime";
+
+import { UnifiedDocumentPage } from "./room-document-surface";
+import { UnifiedDocumentTimelineDialog } from "./unified-document-timeline-dialog";
+
+const page = zhCN.documentPage;
+
+vi.mock("@/features/rooms/files/pdf-preview-adapter-loader", () => ({
+ PdfPreviewAdapterLoader: () => <div>PDF preview</div>,
+}));
+
+vi.mock("./room-document-collaboration", async (importOriginal) => {
+ const { openLocalDocumentSession } =
+ await import("@/test/local-document-session");
+ return {
+ ...(await importOriginal<typeof import("./room-document-collaboration")>()),
+ openRoomDocumentSession: vi.fn(openLocalDocumentSession),
+ };
+});
+
+vi.mock("./room-document-blocknote-editor-loader", () => ({
+ RoomDocumentBlockNoteEditor: () => (
+ <div className="bn-editor">Room BlockNote editor</div>
+ ),
+}));
+
+function renderDocumentPage(runtime: TeamHubRuntime, documentId: string) {
+ const router = createMemoryRouter(
+ [
+ {
+ element: <LibraryLayout />,
+ children: [
+ {
+ element: <UnifiedDocumentPage />,
+ path: "/t/:tenantId/documents/:documentId",
+ },
+ ],
+ },
+ ],
+ { initialEntries: [`/t/tenant-northstar/documents/${documentId}`] },
+ );
+ render(
+ <QueryClientProvider
+ client={
+ new QueryClient({ defaultOptions: { queries: { retry: false } } })
+ }
+ >
+ <TeamHubRuntimeProvider runtime={runtime}>
+ <RouterProvider router={router} />
+ </TeamHubRuntimeProvider>
+ </QueryClientProvider>,
+ );
+}
+
+describe("the Document page in the language on screen", () => {
+ afterEach(() => {
+ resetLanguageForTest();
+ });
+
+ it("words the header, the actions menu and Page history in Chinese", async () => {
+ await setLanguage("zh-CN");
+ const runtime = createDocumentTestRuntime();
+ const document = seedNativeDocument(runtime, "language-page-document");
+
+ renderDocumentPage(runtime, document.id);
+
+ expect(await screen.findByText("Room BlockNote editor")).toBeVisible();
+ expect(screen.getByRole("button", { name: page.share })).toBeVisible();
+ expect(screen.getByRole("button", { name: page.comments })).toBeVisible();
+ expect(
+ screen.getByRole("navigation", { name: page.breadcrumb }),
+ ).toBeVisible();
+ expect(
+ screen.getByRole("button", { name: page.documentMode }),
+ ).toHaveTextContent(new RegExp(`${page.editMode}|${page.readMode}`));
+
+ fireEvent.click(screen.getByRole("button", { name: page.moreActions }));
+ expect(
+ await screen.findByRole("menuitem", { name: zhCN.common.delete }),
+ ).toHaveAttribute("data-voice-risk", "never");
+ fireEvent.click(screen.getByRole("menuitem", { name: page.pageHistory }));
+
+ const dialog = await screen.findByRole("dialog", {
+ name: page.pageHistory,
+ });
+ expect(
+ within(dialog).getByRole("heading", { name: page.pageHistory }),
+ ).toBeVisible();
+ expect(
+ within(dialog).getByRole("button", { name: page.closePageHistory }),
+ ).toHaveAttribute("data-voice-close");
+ expect(await within(dialog).findByText(page.noPageHistory)).toBeVisible();
+ });
+
+ it("dates checkpoints in Chinese and marks Restore as a decision", async () => {
+ await setLanguage("zh-CN");
+ const runtime = createTestTeamHubRuntime();
+ const state = await materializeRoomDocument({
+ materializationId: "language-history",
+ schemaVersion: 1,
+ sourceBytes: new TextEncoder().encode("# Release notes\n\nA line."),
+ sourceKind: "markdown",
+ });
+ const actor = {
+ display_name: "Jenny Bin",
+ id: "actor-jenny",
+ kind: "human" as const,
+ tenant_id: "tenant-northstar",
+ };
+ const entry: TeamHubDocumentHistoryEntry = {
+ contributors: [actor],
+ created_at: "2026-08-27T12:00:00.000Z",
+ created_by: actor,
+ document_id: "document-language-history",
+ id: "history-language",
+ persisted_seq: 1,
+ revision_id: "revision-language",
+ trigger: "manual",
+ };
+ runtime.server.on("GET", "/v0/documents/{documentId}/history", () => ({
+ items: [entry],
+ page: { has_more: false },
+ }));
+ runtime.server.on(
+ "GET",
+ "/v0/document-history/{historyEntryId}/content",
+ (): TeamHubDocumentHistoryContent => ({
+ asset_manifest: [],
+ full_state_fingerprint: state.bytesSha256,
+ history_entry: entry,
+ state_bytes: btoa(String.fromCharCode(...state.stateBytes)),
+ state_bytes_sha256: state.bytesSha256,
+ state_vector: "",
+ }),
+ );
+
+ render(
+ <QueryClientProvider
+ client={
+ new QueryClient({ defaultOptions: { queries: { retry: false } } })
+ }
+ >
+ <UnifiedDocumentTimelineDialog
+ client={runtime.client}
+ documentId={entry.document_id}
+ onClose={() => undefined}
+ tenantId="tenant-northstar"
+ />
+ </QueryClientProvider>,
+ );
+
+ const restore = await screen.findByRole("button", {
+ name: page.restoreCheckpoint,
+ });
+ expect(restore).toHaveAttribute("data-voice-risk", "confirm");
+ const date = formatDateTime(
+ entry.created_at,
+ { dateStyle: "medium", timeStyle: "short" },
+ "zh-CN",
+ );
+ expect(date).not.toBe(
+ formatDateTime(
+ entry.created_at,
+ { dateStyle: "medium", timeStyle: "short" },
+ "en-US",
+ ),
+ );
+ expect(screen.getAllByText(date).length).toBeGreaterThan(0);
+ expect(
+ screen.getByRole("region", { name: page.historyPreview }),
+ ).toBeVisible();
+ });
+});
diff --git a/apps/web/src/features/rooms/documents/document-page.messages.ts b/apps/web/src/features/rooms/documents/document-page.messages.ts
new file mode 100644
index 00000000..b746b5ec
--- /dev/null
+++ b/apps/web/src/features/rooms/documents/document-page.messages.ts
@@ -0,0 +1,98 @@
+import { defineMessages } from "@/i18n/messages";
+
+/**
+ * The Document page: header, body, save status, actions menu, title, page
+ * history, Version preview and presence. Document titles, owner names and
+ * error messages TeamHub sends are data and are shown as they arrive.
+ */
+export const documentPageMessages = defineMessages("documentPage", {
+ // The name of a Document that has no title yet, and the header label.
+ document: "Document",
+ openLibraryPages: "Open Library pages",
+ libraryPages: "Library pages",
+ mail: "Mail",
+ share: "Share",
+ comments: "Comments",
+ breadcrumb: "Breadcrumb",
+ // Where a Document comes from, when it is not in the Library tree.
+ contextRoom: "Room",
+ contextWorkItem: "Work Item",
+ contextWiki: "Wiki",
+ contextDocuments: "Documents",
+ documentMode: "Document mode",
+ read: "Read",
+ currentMode: "Current mode",
+ editMode: "Edit mode",
+ readMode: "Read mode",
+ moreActions: "More Document actions",
+ pageHistory: "Page history",
+
+ openingWikiPage: "Opening Wiki page...",
+ byOwner: "By {name}",
+ openingDocument: "Opening document",
+ openingDocumentStatus: "Opening document...",
+ downloadRecoveryCopy: "Download recovery copy",
+ recoveryCopy: "Recovery copy",
+ connectionStatus: "Document connection status",
+ connectionFailed: "Connection failed",
+ retryConnection: "Retry connection",
+ accessMode: "Document access mode",
+ readOnly: "Read only",
+ saveStatus: "Document save status",
+ saved: "Saved",
+ saveProtocolError: "Save protocol error",
+ offlineChangesPending: "Offline changes pending",
+ offline: "Offline",
+ connecting: "Connecting...",
+ saving: "Saving...",
+
+ titleUpdateFailed: "The title could not be updated.",
+ renameDocument: "Rename document",
+ documentTitle: "Document title",
+ trashFailed: "The Document could not be moved to trash.",
+ exportFailed: "The Document could not be exported.",
+ duplicateFailed: "The Document could not be duplicated.",
+ resizeComments: "Resize Document comments",
+
+ closePageHistory: "Close Page history",
+ noPageHistory: "No page history saved yet.",
+ loadingTimeline: "Loading timeline...",
+ historyPreview: "History preview",
+ highlightChanges: "Highlight changes",
+ selectCheckpoint: "Select a checkpoint to preview it.",
+ loadingCheckpoint: "Loading checkpoint...",
+ historicalContent: "Historical Document content",
+ checkpointIdentical:
+ "This checkpoint is identical to the previous checkpoint.",
+ checkpointEmpty: "This checkpoint has no content.",
+ restoreCheckpoint: "Restore checkpoint",
+ alreadyCurrent: "Already current.",
+ restored: "Restored.",
+ revisionInconsistent: "History Revision identity is inconsistent.",
+ revisionIntegrityFailed:
+ "History Revision bytes failed integrity verification.",
+ revisionInvalid: "History Revision bytes are invalid.",
+ // Joins names in a list, such as the people who changed a checkpoint.
+ listSeparator: ", ",
+
+ noPublishedVersion: "This Document has no published Version.",
+ previewLoadFailed: "Document preview could not be loaded.",
+ downloadFailed: "Document download failed.",
+ retryPreview: "Retry preview",
+ loadingPreview: "Loading preview…",
+ previewUnavailable: "Preview is unavailable for this Version.",
+
+ metadataUnavailable: "Document metadata is unavailable.",
+ documentUnavailable: "Document is unavailable.",
+ collaborationOpenFailed: "Document collaboration could not be opened.",
+
+ // {names} is the list of people, joined with listSeparator.
+ peopleInDocument: "{count} people in this document: {names}",
+ peopleViewing: {
+ one: "{count} person viewing",
+ other: "{count} people viewing",
+ },
+ nameYou: "{name} (you)",
+ collaborator: "Collaborator",
+ cursor: "{name} cursor",
+});
diff --git a/apps/web/src/features/rooms/documents/document-share-dialog.tsx b/apps/web/src/features/rooms/documents/document-share-dialog.tsx
index 0f5867e8..8fc8fc33 100644
--- a/apps/web/src/features/rooms/documents/document-share-dialog.tsx
+++ b/apps/web/src/features/rooms/documents/document-share-dialog.tsx
@@ -19,9 +19,21 @@ import { teamHubData } from "@/features/teamhub/teamhub-api";
import { type TeamHubClient } from "@/features/teamhub/teamhub-client";
import { DocumentLinkSharing } from "./document-link-sharing";
import type { TeamHubDocumentShareViewV2 } from "@/features/teamhub/teamhub-types";
+import { libraryMessages } from "@/features/library/library.messages";
+import { commonMessages } from "@/i18n/common.messages";
+import { translate, type Translate } from "@/i18n/language";
+import { useT } from "@/i18n/use-translation";
+
+import { documentShareMessages as m } from "./document-share.messages";
const roles = ["viewer", "editor", "manager"] as const;
type DirectRole = (typeof roles)[number];
+const roleMessages = {
+ editor: libraryMessages.roleEditor,
+ manager: libraryMessages.roleManager,
+ owner: libraryMessages.roleOwner,
+ viewer: libraryMessages.roleViewer,
+};
export function DocumentShareDialog({
client,
@@ -36,6 +48,7 @@ export function DocumentShareDialog({
ownerActorId: string;
tenantId: string;
}) {
+ const t = useT();
const [pendingSourceId, setPendingSourceId] = useState<string | null>(null);
const [actionError, setActionError] = useState<string | null>(null);
const [view, setView] = useState<"share" | "manage">("share");
@@ -91,7 +104,7 @@ export function DocumentShareDialog({
).toString(),
);
} catch {
- setActionError("The Document link could not be copied.");
+ setActionError(translate(m.linkCopyFailed));
}
}
@@ -115,9 +128,7 @@ export function DocumentShareDialog({
);
await share.refetch();
} catch {
- setActionError(
- "Some collaborators could not be invited. Refresh and try again.",
- );
+ setActionError(translate(m.inviteFailed));
} finally {
setPendingSourceId(null);
}
@@ -139,9 +150,7 @@ export function DocumentShareDialog({
);
await share.refetch();
} catch {
- setActionError(
- "The Document could not be removed from this Room. Refresh and try again.",
- );
+ setActionError(translate(m.removeFromRoomFailed));
throw new Error("Remove from Room failed");
} finally {
setPendingSourceId(null);
@@ -168,7 +177,7 @@ export function DocumentShareDialog({
);
await share.refetch();
} catch {
- setActionError("The collaborator permission could not be updated.");
+ setActionError(translate(m.permissionUpdateFailed));
} finally {
setPendingSourceId(null);
}
@@ -190,7 +199,7 @@ export function DocumentShareDialog({
);
await share.refetch();
} catch {
- setActionError("The collaborator could not be removed.");
+ setActionError(translate(m.removeCollaboratorFailed));
} finally {
setPendingSourceId(null);
}
@@ -198,7 +207,7 @@ export function DocumentShareDialog({
return (
<ModalDialog
- ariaLabel="Share Document"
+ ariaLabel={t(m.shareDocument)}
className="flex flex-col overflow-hidden"
closeOnBackdrop
onClose={onClose}
@@ -210,7 +219,7 @@ export function DocumentShareDialog({
<div className="flex items-center gap-1.5">
{view === "manage" ? (
<Button
- aria-label="Back to share"
+ aria-label={t(m.backToShare)}
onClick={() => setView("share")}
size="compactIcon"
tone="ghost"
@@ -219,12 +228,14 @@ export function DocumentShareDialog({
</Button>
) : null}
<h2 className="text-base font-semibold text-app-ink">
- {view === "manage" ? "Manage collaborators" : "Share"}
+ {view === "manage" ? t(m.manageCollaborators) : t(m.share)}
</h2>
</div>
{share.data ? (
<p className="mt-0.5 text-xs text-app-muted">
- Your access: {roleLabel(share.data.caller_content_role)}
+ {t(m.yourAccess, {
+ role: roleLabel(share.data.caller_content_role, t),
+ })}
</p>
) : null}
</div>
@@ -240,10 +251,10 @@ export function DocumentShareDialog({
>
<Icon icon={Alert02Icon} size={20} className="text-app-danger" />
<p className="max-w-sm text-sm text-app-body">
- Sharing settings are unavailable.
+ {t(m.settingsUnavailable)}
</p>
<Button onClick={() => void share.refetch()} tone="secondary">
- <Icon icon={RefreshIcon} size={14} /> Retry
+ <Icon icon={RefreshIcon} size={14} /> {t(commonMessages.retry)}
</Button>
</div>
) : share.data ? (
@@ -324,6 +335,7 @@ function ShareContent({
pendingSourceId: string | null;
share: TeamHubDocumentShareViewV2;
}) {
+ const t = useT();
const direct = share.sources.filter((item) => sourceGroup(item) === "direct");
const rooms = share.sources.filter(
(item) =>
@@ -348,17 +360,17 @@ function ShareContent({
>
<span>{actionError}</span>
<Button onClick={onRefresh} size="compact" tone="secondary">
- Refresh
+ {t(m.refresh)}
</Button>
</div>
) : null}
{pendingSourceId ? (
<p
- aria-label="Share change status"
+ aria-label={t(m.changeStatus)}
className="text-sm text-app-muted"
role="status"
>
- Saving access...
+ {t(m.savingAccess)}
</p>
) : null}
<section aria-labelledby="invite-collaborators-heading">
@@ -367,7 +379,7 @@ function ShareContent({
className="text-base font-semibold text-app-ink"
id="invite-collaborators-heading"
>
- Invite collaborators
+ {t(m.inviteCollaborators)}
</h3>
<CollaboratorAvatarButton
actors={collaboratorActors}
@@ -405,9 +417,10 @@ function CollaboratorAvatarButton({
count: number;
onClick: () => void;
}) {
+ const t = useT();
return (
<button
- aria-label={`Manage ${count} active collaborators`}
+ aria-label={t(m.manageActiveCollaborators, { count })}
className="flex min-h-9 items-center rounded-full px-1.5 outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"
onClick={onClick}
type="button"
@@ -430,7 +443,7 @@ function CollaboratorAvatarButton({
) : null}
</span>
<span className="ml-2 text-xs font-medium text-app-muted">
- {count} active
+ {t(m.activeCount, { count })}
</span>
</button>
);
@@ -457,6 +470,7 @@ function ManageCollaborators({
pendingSourceId: string | null;
share: TeamHubDocumentShareViewV2;
}) {
+ const t = useT();
const [removeTarget, setRemoveTarget] = useState<
TeamHubDocumentShareViewV2["sources"][number] | null
>(null);
@@ -488,7 +502,7 @@ function ManageCollaborators({
className="text-sm font-medium text-app-muted"
id="direct-collaborators-heading"
>
- Agents with direct access
+ {t(m.agentsWithDirectAccess)}
</h3>
{direct.length ? (
<div className="mt-2 divide-y divide-app-border">
@@ -513,10 +527,10 @@ function ManageCollaborators({
<p className="truncate text-sm font-medium text-app-ink">
{actor?.display_name ?? item.label}
</p>
- <p className="text-xs text-app-muted">Agent</p>
+ <p className="text-xs text-app-muted">{t(m.agent)}</p>
</div>
<Select
- aria-label={`${item.label} permission`}
+ aria-label={t(m.permission, { label: item.label })}
className="w-auto"
disabled={disabled}
onValueChange={(role) => {
@@ -534,10 +548,10 @@ function ManageCollaborators({
>
{roles.map((role) => (
<SelectItem key={role} value={role}>
- {roleLabel(role)}
+ {roleLabel(role, t)}
</SelectItem>
))}
- <SelectItem value="remove">Remove access</SelectItem>
+ <SelectItem value="remove">{t(m.removeAccess)}</SelectItem>
</Select>
</div>
);
@@ -545,7 +559,7 @@ function ManageCollaborators({
</div>
) : (
<p className="mt-3 text-sm text-app-muted">
- No direct collaborators yet.
+ {t(m.noDirectCollaborators)}
</p>
)}
</section>
@@ -561,13 +575,14 @@ function ManageCollaborators({
closeOnBackdrop
onClose={() => setRemoveTarget(null)}
size="sm"
- title={`Remove ${removeTarget.label}?`}
+ title={t(m.removeTitle, { label: removeTarget.label })}
footer={
<>
<Button onClick={() => setRemoveTarget(null)} tone="ghost">
- Cancel
+ {t(commonMessages.cancel)}
</Button>
<Button
+ data-voice-risk="never"
disabled={disabled}
onClick={() => {
void onRemove(
@@ -577,14 +592,13 @@ function ManageCollaborators({
}}
tone="danger"
>
- Remove access
+ {t(m.removeAccess)}
</Button>
</>
}
>
<p className="px-5 py-4 text-sm text-app-muted">
- Their direct access will be removed. Access from a Room, Task, or
- Wiki is not affected.
+ {t(m.removeAccessBody)}
</p>
</ModalDialog>
) : null}
@@ -601,6 +615,7 @@ function RoomBindingSection({
onRemove: (roomId: string, version: number) => Promise<void>;
rooms: TeamHubDocumentShareViewV2["sources"];
}) {
+ const t = useT();
const [selected, setSelected] = useState<
TeamHubDocumentShareViewV2["sources"][number] | null
>(null);
@@ -613,7 +628,7 @@ function RoomBindingSection({
className="text-sm font-semibold text-app-ink"
id="shared-rooms-heading"
>
- Shared with Rooms
+ {t(m.sharedWithRooms)}
</h3>
<div className="mt-2 divide-y divide-app-border">
{rooms.map((room) => (
@@ -626,16 +641,17 @@ function RoomBindingSection({
{room.label}
</span>
<span className="block text-xs text-app-muted">
- {roleLabel(room.source.role)}
+ {roleLabel(room.source.role, t)}
</span>
</div>
<Button
+ data-voice-risk="never"
disabled={disabled}
onClick={() => setSelected(room)}
size="compact"
tone="ghost"
>
- Remove from Room
+ {t(m.removeFromRoom)}
</Button>
</div>
))}
@@ -645,13 +661,14 @@ function RoomBindingSection({
closeOnBackdrop
onClose={() => setSelected(null)}
size="sm"
- title={`Remove from ${selected.label}?`}
+ title={t(m.removeFromRoomTitle, { label: selected.label })}
footer={
<>
<Button onClick={() => setSelected(null)} tone="ghost">
- Cancel
+ {t(commonMessages.cancel)}
</Button>
<Button
+ data-voice-risk="never"
disabled={disabled}
onClick={() => {
void onRemove(
@@ -661,14 +678,13 @@ function RoomBindingSection({
}}
tone="danger"
>
- Remove
+ {t(commonMessages.remove)}
</Button>
</>
}
>
<p className="px-5 py-4 text-sm text-app-muted">
- Room members will lose this source. Direct, Task, and Wiki access
- are not affected.
+ {t(m.removeFromRoomBody)}
</p>
</ModalDialog>
) : null}
@@ -677,17 +693,18 @@ function RoomBindingSection({
}
function CopyLinkSection({ onCopyLink }: { onCopyLink: () => void }) {
+ const t = useT();
return (
<section className="border-t border-app-border pt-5">
<div className="flex items-center justify-between gap-4">
<div>
- <h3 className="text-sm font-semibold text-app-ink">Document link</h3>
- <p className="mt-1 text-xs text-app-muted">
- Copying the link does not change who can access this document.
- </p>
+ <h3 className="text-sm font-semibold text-app-ink">
+ {t(m.documentLink)}
+ </h3>
+ <p className="mt-1 text-xs text-app-muted">{t(m.copyLinkHint)}</p>
</div>
<Button onClick={onCopyLink} tone="secondary">
- <Icon icon={Copy01Icon} size={14} /> Copy link
+ <Icon icon={Copy01Icon} size={14} /> {t(libraryMessages.copyLink)}
</Button>
</div>
</section>
@@ -713,6 +730,7 @@ function InviteCollaboratorsField({
onInvite: (targetIds: string[], role: DirectRole) => Promise<void>;
onRetry: () => void;
}) {
+ const t = useT();
const [open, setOpen] = useState(false);
const [query, setQuery] = useState("");
const [selected, setSelected] = useState<string[]>([]);
@@ -725,15 +743,15 @@ function InviteCollaboratorsField({
<div className="mt-3">
<div className="flex items-center rounded-lg border border-input bg-card pr-1 transition-colors hover:border-border-hover focus-within:border-foreground focus-within:ring-2 focus-within:ring-ring">
<input
- aria-label="Search collaborators"
+ aria-label={t(m.searchCollaborators)}
className="h-9 min-w-0 flex-1 bg-transparent px-3 text-sm text-app-ink outline-none placeholder:text-app-placeholder"
onChange={(event) => setQuery(event.target.value)}
onFocus={() => setOpen(true)}
- placeholder="Search Agents"
+ placeholder={t(m.searchAgents)}
value={query}
/>
<Button
- aria-label="Add collaborators"
+ aria-label={t(m.addCollaborators)}
disabled={disabled}
onClick={() => setOpen(true)}
size="icon"
@@ -746,7 +764,7 @@ function InviteCollaboratorsField({
<div className="mt-2 overflow-hidden rounded-md border border-app-border bg-popover shadow-md">
{actorsPending ? (
<p className="px-3 py-3 text-sm text-app-muted">
- Loading collaborators...
+ {t(m.loadingCollaborators)}
</p>
) : actorsError ? (
<button
@@ -754,11 +772,11 @@ function InviteCollaboratorsField({
onClick={onRetry}
type="button"
>
- Unable to load. Retry
+ {t(m.unableToLoad)}
</button>
) : filtered.length === 0 ? (
<p className="px-3 py-3 text-sm text-app-muted">
- No matching collaborators.
+ {t(m.noMatchingCollaborators)}
</p>
) : (
<div className="max-h-52 overflow-y-auto p-1">
@@ -782,7 +800,7 @@ function InviteCollaboratorsField({
{actor.display_name}
</span>
<span className="block text-xs text-app-muted">
- {actor.kind === "agent" ? "Agent" : "Person"}
+ {actor.kind === "agent" ? t(m.agent) : t(m.person)}
</span>
</span>
<span
@@ -790,7 +808,7 @@ function InviteCollaboratorsField({
checked ? "font-medium text-app-ink" : "text-app-muted"
}
>
- {checked ? "Selected" : "Select"}
+ {checked ? t(m.selected) : t(m.select)}
</span>
</button>
);
@@ -799,14 +817,14 @@ function InviteCollaboratorsField({
)}
<div className="flex items-center justify-between gap-2 border-t border-app-border px-3 py-2">
<Select
- aria-label="Invite role"
+ aria-label={t(m.inviteRole)}
className="h-8 w-auto"
onValueChange={(value) => setRole(value as DirectRole)}
value={role}
>
{roles.map((option) => (
<SelectItem key={option} value={option}>
- {roleLabel(option)}
+ {roleLabel(option, t)}
</SelectItem>
))}
</Select>
@@ -819,9 +837,10 @@ function InviteCollaboratorsField({
size="compact"
tone="ghost"
>
- Cancel
+ {t(commonMessages.cancel)}
</Button>
<Button
+ data-voice-risk="confirm"
disabled={!selected.length || disabled}
onClick={() =>
void onInvite(selected, role).then(() => {
@@ -831,7 +850,9 @@ function InviteCollaboratorsField({
}
size="compact"
>
- Invite{selected.length ? ` (${selected.length})` : ""}
+ {selected.length
+ ? t(m.inviteCount, { count: selected.length })
+ : t(m.invite)}
</Button>
</div>
</div>
@@ -842,9 +863,10 @@ function InviteCollaboratorsField({
}
function ShareLoading() {
+ const t = useT();
return (
- <div aria-label="Share loading" className="space-y-3" role="status">
- <span className="sr-only">Loading access</span>
+ <div aria-label={t(m.shareLoading)} className="space-y-3" role="status">
+ <span className="sr-only">{t(m.loadingAccess)}</span>
{[0, 1, 2].map((item) => (
<div
className="h-12 animate-pulse rounded-lg bg-muted motion-reduce:animate-none"
@@ -855,8 +877,10 @@ function ShareLoading() {
);
}
-function roleLabel(role: string) {
- return role.charAt(0).toUpperCase() + role.slice(1);
+function roleLabel(role: string, t: Translate) {
+ return role in roleMessages
+ ? t(roleMessages[role as keyof typeof roleMessages])
+ : role.charAt(0).toUpperCase() + role.slice(1);
}
function sourceGroup(item: TeamHubDocumentShareViewV2["sources"][number]) {
return item.source_group ?? item.source.source_kind;
diff --git a/apps/web/src/features/rooms/documents/document-share-language.test.tsx b/apps/web/src/features/rooms/documents/document-share-language.test.tsx
new file mode 100644
index 00000000..fedc66e5
--- /dev/null
+++ b/apps/web/src/features/rooms/documents/document-share-language.test.tsx
@@ -0,0 +1,207 @@
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { createMemoryRouter, RouterProvider } from "react-router";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import { LibraryLayout } from "@/features/library/library-layout";
+import type { TeamHubClient } from "@/features/teamhub/teamhub-client";
+import type { DocumentLinkPolicy } from "@/features/teamhub/teamhub-document-links";
+import {
+ TeamHubRuntimeProvider,
+ type TeamHubRuntime,
+} from "@/features/teamhub/teamhub-runtime";
+import { resetLanguageForTest, setLanguage } from "@/i18n/language";
+import zhCN from "@/i18n/locales/zh-CN.json";
+import {
+ createDocumentTestRuntime,
+ seedNativeDocument,
+} from "@/test/document-scenarios";
+
+import { DocumentLinkSharing } from "./document-link-sharing";
+import { UnifiedDocumentPage } from "./room-document-surface";
+
+const share = zhCN.documentShare;
+
+vi.mock("@/features/rooms/files/pdf-preview-adapter-loader", () => ({
+ PdfPreviewAdapterLoader: () => <div>PDF preview</div>,
+}));
+
+vi.mock("./room-document-collaboration", async (importOriginal) => {
+ const { openLocalDocumentSession } =
+ await import("@/test/local-document-session");
+ return {
+ ...(await importOriginal<typeof import("./room-document-collaboration")>()),
+ openRoomDocumentSession: vi.fn(openLocalDocumentSession),
+ };
+});
+
+vi.mock("./room-document-blocknote-editor-loader", () => ({
+ RoomDocumentBlockNoteEditor: () => (
+ <div className="bn-editor">Room BlockNote editor</div>
+ ),
+}));
+
+function renderDocumentPage(runtime: TeamHubRuntime, documentId: string) {
+ const router = createMemoryRouter(
+ [
+ {
+ element: <LibraryLayout />,
+ children: [
+ {
+ element: <UnifiedDocumentPage />,
+ path: "/t/:tenantId/documents/:documentId",
+ },
+ ],
+ },
+ ],
+ { initialEntries: [`/t/tenant-northstar/documents/${documentId}`] },
+ );
+ render(
+ <QueryClientProvider
+ client={
+ new QueryClient({ defaultOptions: { queries: { retry: false } } })
+ }
+ >
+ <TeamHubRuntimeProvider runtime={runtime}>
+ <RouterProvider router={router} />
+ </TeamHubRuntimeProvider>
+ </QueryClientProvider>,
+ );
+}
+
+describe("Document sharing in the language on screen", () => {
+ afterEach(() => {
+ resetLanguageForTest();
+ });
+
+ it("words the share dialog in Chinese and marks the removals", async () => {
+ await setLanguage("zh-CN");
+ const runtime = createDocumentTestRuntime();
+ const document = seedNativeDocument(runtime, "language-share-document");
+ runtime.server.on(
+ "GET",
+ "/v0/documents/{documentId}/collaborators",
+ () => ({
+ caller_content_role: "owner",
+ can_manage_collaborators: true,
+ management_capabilities: {
+ can_change_ownership: true,
+ can_update_external_policy: true,
+ can_update_link_policy: true,
+ },
+ schema_version: 2,
+ sources: [
+ {
+ label: "Alex",
+ source: {
+ created_at: "2026-08-29T08:00:00Z",
+ grantor_actor_id: document.owner.id,
+ provenance: { kind: "direct_grant", schema_version: 2 },
+ role: "editor",
+ schema_version: 2,
+ source_id: "direct-alex",
+ source_kind: "direct",
+ source_version: 3,
+ status: "active",
+ target: { id: "actor-alex", kind: "agent" },
+ updated_at: "2026-08-29T08:00:00Z",
+ },
+ },
+ {
+ label: "Launch Room",
+ source: {
+ created_at: "2026-08-29T08:00:00Z",
+ provenance: {
+ binding_kind: "room",
+ context_id: "room-launch",
+ kind: "context_binding",
+ schema_version: 2,
+ },
+ role: "editor",
+ schema_version: 2,
+ source_id: "room-binding-launch",
+ source_kind: "context",
+ source_version: 7,
+ status: "active",
+ updated_at: "2026-08-29T08:00:00Z",
+ },
+ },
+ ],
+ }),
+ );
+
+ renderDocumentPage(runtime, document.id);
+ fireEvent.click(
+ await screen.findByRole("button", { name: zhCN.documentPage.share }),
+ );
+
+ expect(
+ await screen.findByRole("dialog", { name: share.shareDocument }),
+ ).toBeVisible();
+ expect(
+ await screen.findByText(
+ share.yourAccess.replace("{role}", zhCN.library.roleOwner),
+ ),
+ ).toBeVisible();
+ expect(
+ screen.getByRole("heading", { name: share.sharedWithRooms }),
+ ).toBeVisible();
+ expect(
+ screen.getByRole("button", { name: share.removeFromRoom }),
+ ).toHaveAttribute("data-voice-risk", "never");
+ expect(
+ screen.getByRole("button", { name: zhCN.library.copyLink }),
+ ).toBeVisible();
+
+ const manage = screen.getByRole("button", {
+ name: share.manageActiveCollaborators.replace("{count}", "2"),
+ });
+ expect(manage).toHaveTextContent(share.activeCount.replace("{count}", "2"));
+ fireEvent.click(manage);
+ expect(
+ screen.getByRole("heading", { name: share.manageCollaborators }),
+ ).toBeVisible();
+ expect(
+ screen.getByRole("button", { name: share.backToShare }),
+ ).toBeVisible();
+ expect(
+ screen.getByRole("combobox", {
+ name: share.permission.replace("{label}", "Alex"),
+ }),
+ ).toBeVisible();
+ });
+
+ it("words link sharing in Chinese and marks Reset link as a decision", async () => {
+ await setLanguage("zh-CN");
+ const policy: DocumentLinkPolicy = {
+ document_id: "doc-1",
+ id: "link-1",
+ role: "viewer",
+ status: "active",
+ version: 1,
+ };
+ const client = {
+ documentLinks: {
+ get: vi.fn(async () => policy),
+ revoke: vi.fn(),
+ set: vi.fn(),
+ },
+ } as unknown as TeamHubClient;
+
+ render(
+ <QueryClientProvider client={new QueryClient()}>
+ <DocumentLinkSharing client={client} documentId="doc-1" />
+ </QueryClientProvider>,
+ );
+
+ expect(
+ screen.getByRole("heading", { name: share.anyoneWithLink }),
+ ).toBeVisible();
+ const access = screen.getByRole("combobox", { name: share.linkAccess });
+ await waitFor(() => expect(access).toBeEnabled());
+ expect(access).toHaveTextContent(share.canView);
+ expect(
+ screen.getByRole("button", { name: share.resetLink }),
+ ).toHaveAttribute("data-voice-risk", "confirm");
+ });
+});
diff --git a/apps/web/src/features/rooms/documents/document-share.messages.ts b/apps/web/src/features/rooms/documents/document-share.messages.ts
new file mode 100644
index 00000000..98444c38
--- /dev/null
+++ b/apps/web/src/features/rooms/documents/document-share.messages.ts
@@ -0,0 +1,71 @@
+import { defineMessages } from "@/i18n/messages";
+
+/**
+ * The Document share dialog and its link sharing section. Agent, person and
+ * Room names TeamHub sends are data and are shown as they arrive.
+ */
+export const documentShareMessages = defineMessages("documentShare", {
+ shareDocument: "Share Document",
+ backToShare: "Back to share",
+ share: "Share",
+ manageCollaborators: "Manage collaborators",
+ // {role} is the access role, such as Viewer or Editor.
+ yourAccess: "Your access: {role}",
+ settingsUnavailable: "Sharing settings are unavailable.",
+ refresh: "Refresh",
+ changeStatus: "Share change status",
+ savingAccess: "Saving access...",
+ inviteCollaborators: "Invite collaborators",
+ manageActiveCollaborators: "Manage {count} active collaborators",
+ activeCount: "{count} active",
+ agentsWithDirectAccess: "Agents with direct access",
+ agent: "Agent",
+ person: "Person",
+ // {label} is the name of an Agent with access.
+ permission: "{label} permission",
+ removeAccess: "Remove access",
+ noDirectCollaborators: "No direct collaborators yet.",
+ removeTitle: "Remove {label}?",
+ removeAccessBody:
+ "Their direct access will be removed. Access from a Room, Task, or Wiki is not affected.",
+ sharedWithRooms: "Shared with Rooms",
+ removeFromRoom: "Remove from Room",
+ // {label} is the name of a Room.
+ removeFromRoomTitle: "Remove from {label}?",
+ removeFromRoomBody:
+ "Room members will lose this source. Direct, Task, and Wiki access are not affected.",
+ documentLink: "Document link",
+ copyLinkHint:
+ "Copying the link does not change who can access this document.",
+ searchCollaborators: "Search collaborators",
+ searchAgents: "Search Agents",
+ addCollaborators: "Add collaborators",
+ loadingCollaborators: "Loading collaborators...",
+ unableToLoad: "Unable to load. Retry",
+ noMatchingCollaborators: "No matching collaborators.",
+ selected: "Selected",
+ select: "Select",
+ inviteRole: "Invite role",
+ invite: "Invite",
+ inviteCount: "Invite ({count})",
+ shareLoading: "Share loading",
+ loadingAccess: "Loading access",
+ linkCopyFailed: "The Document link could not be copied.",
+ inviteFailed:
+ "Some collaborators could not be invited. Refresh and try again.",
+ removeFromRoomFailed:
+ "The Document could not be removed from this Room. Refresh and try again.",
+ permissionUpdateFailed: "The collaborator permission could not be updated.",
+ removeCollaboratorFailed: "The collaborator could not be removed.",
+
+ linkUpdateFailed: "Link sharing could not be updated.",
+ anyoneWithLink: "Anyone with the link",
+ linkAccess: "Link access",
+ linkDisabled: "Disabled",
+ canView: "Can view",
+ canEdit: "Can edit",
+ resetLink: "Reset link",
+ copySharedLink: "Copy shared link",
+ sharedLinkCopyFailed: "Could not copy the link.",
+ linkSharingUnavailable: "Link sharing is unavailable.",
+});
diff --git a/apps/web/src/features/rooms/documents/document-version-preview.tsx b/apps/web/src/features/rooms/documents/document-version-preview.tsx
index 3fbc059f..cfbf5928 100644
--- a/apps/web/src/features/rooms/documents/document-version-preview.tsx
+++ b/apps/web/src/features/rooms/documents/document-version-preview.tsx
@@ -28,6 +28,11 @@ import {
import { ArtifactReadingViewport } from "../files/artifact-reading-viewport";
import type { ArtifactReadingPosition } from "../files/artifact-preview-cache";
import { PreviewSessionExpiryNotice } from "../files/preview-session-expiry-notice";
+import { libraryMessages } from "@/features/library/library.messages";
+import { translate } from "@/i18n/language";
+import { useT } from "@/i18n/use-translation";
+
+import { documentPageMessages as m } from "./document-page.messages";
interface LoadedDocumentPreview {
blob?: Blob;
@@ -54,6 +59,7 @@ export function DocumentVersionPreview({
document: TeamHubDocument;
knownVersion?: TeamHubDocumentVersion;
}) {
+ const t = useT();
const [attempt, setAttempt] = useState(0);
const [error, setError] = useState<string | null>(null);
const [preview, setPreview] = useState<LoadedDocumentPreview | null>(null);
@@ -72,7 +78,7 @@ export function DocumentVersionPreview({
setPreview(null);
if (!versionId && document.representation_format !== "html") {
- setError("This Document has no published Version.");
+ setError(translate(m.noPublishedVersion));
transferRef.current = null;
return () => controller.abort();
}
@@ -98,7 +104,7 @@ export function DocumentVersionPreview({
setError(
loadError instanceof Error
? loadError.message
- : "Document preview could not be loaded.",
+ : translate(m.previewLoadFailed),
);
}
if (transferRef.current === controller) transferRef.current = null;
@@ -152,7 +158,7 @@ export function DocumentVersionPreview({
setError(
downloadError instanceof Error
? downloadError.message
- : "Document download failed.",
+ : translate(m.downloadFailed),
);
}
} finally {
@@ -180,7 +186,7 @@ export function DocumentVersionPreview({
onClick={() => setAttempt((value) => value + 1)}
tone="secondary"
>
- <Icon icon={RefreshIcon} size={14} /> Retry preview
+ <Icon icon={RefreshIcon} size={14} /> {t(m.retryPreview)}
</Button>
) : null}
</div>
@@ -194,7 +200,7 @@ export function DocumentVersionPreview({
className="flex min-h-full items-center justify-center gap-2 text-sm text-app-muted"
role="status"
>
- <Spinner size={16} /> Loading preview…
+ <Spinner size={16} /> {t(m.loadingPreview)}
</div>
);
}
@@ -208,8 +214,7 @@ export function DocumentVersionPreview({
className="mx-auto text-app-muted"
/>
<p className="mt-3 text-sm text-app-muted">
- {preview.decision.reason ??
- "Preview is unavailable for this Version."}
+ {preview.decision.reason ?? t(m.previewUnavailable)}
</p>
<Button
className="mt-4"
@@ -222,7 +227,7 @@ export function DocumentVersionPreview({
) : (
<Icon icon={Download04Icon} size={14} />
)}
- Download
+ {t(libraryMessages.download)}
</Button>
</div>
</div>
diff --git a/apps/web/src/features/rooms/documents/document-version-selection-comment-control.tsx b/apps/web/src/features/rooms/documents/document-version-selection-comment-control.tsx
index 3437fc6d..a676271a 100644
--- a/apps/web/src/features/rooms/documents/document-version-selection-comment-control.tsx
+++ b/apps/web/src/features/rooms/documents/document-version-selection-comment-control.tsx
@@ -3,6 +3,9 @@ import { Icon } from "@/components/ui/icon";
import { useEffect, useState, type MutableRefObject } from "react";
import { Button } from "@/components/ui/button";
+import { useT } from "@/i18n/use-translation";
+
+import { documentCommentsMessages as m } from "./document-comments.messages";
interface VersionSelection {
left: number;
@@ -19,6 +22,7 @@ export function DocumentVersionSelectionCommentControl({
onComment: (quotedText: string) => void;
rootRef: MutableRefObject<HTMLElement | null>;
}) {
+ const t = useT();
const [selection, setSelection] = useState<VersionSelection | null>(null);
useEffect(() => {
@@ -88,7 +92,7 @@ export function DocumentVersionSelectionCommentControl({
style={{ left: selection.left, top: selection.top }}
>
<Button
- aria-label="Add comment to selected text"
+ aria-label={t(m.addCommentToSelection)}
className="bg-app-hover text-app-ink"
onClick={() => {
onComment(selection.quotedText);
@@ -96,7 +100,7 @@ export function DocumentVersionSelectionCommentControl({
}}
onMouseDown={(event) => event.preventDefault()}
size="compactIcon"
- title="Add comment"
+ title={t(m.addComment)}
tone="ghost"
>
<Icon icon={Comment01Icon} />
diff --git a/apps/web/src/features/rooms/documents/editable-document-title.tsx b/apps/web/src/features/rooms/documents/editable-document-title.tsx
index 5265818a..317431af 100644
--- a/apps/web/src/features/rooms/documents/editable-document-title.tsx
+++ b/apps/web/src/features/rooms/documents/editable-document-title.tsx
@@ -1,5 +1,10 @@
import { useCallback, useRef, useState } from "react";
+import { translate } from "@/i18n/language";
+import { useT } from "@/i18n/use-translation";
+
+import { documentPageMessages as m } from "./document-page.messages";
+
export function EditableDocumentTitle({
autoFocus = false,
display = "breadcrumb",
@@ -17,6 +22,7 @@ export function EditableDocumentTitle({
onCommit?: () => void;
onRename: (name: string) => Promise<void>;
}) {
+ const t = useT();
const [editing, setEditing] = useState(autoFocus);
const [draft, setDraft] = useState<string>();
const [committedName, setCommittedName] = useState<{
@@ -65,7 +71,7 @@ export function EditableDocumentTitle({
setError(
renameError instanceof Error
? renameError.message
- : "The title could not be updated.",
+ : translate(m.titleUpdateFailed),
);
return false;
} finally {
@@ -94,7 +100,7 @@ export function EditableDocumentTitle({
setDraft(visibleName);
setEditing(true);
}}
- title="Rename document"
+ title={t(m.renameDocument)}
type="button"
>
{display === "page" ? (
@@ -137,7 +143,7 @@ export function EditableDocumentTitle({
}}
>
<input
- aria-label="Document title"
+ aria-label={t(m.documentTitle)}
className={
display === "page"
? "room-document-page-title block h-auto w-full min-w-0 border-0 bg-transparent px-0 py-0 font-normal text-app-ink outline-none shadow-none focus:border-0 focus:outline-none focus:ring-0"
diff --git a/apps/web/src/features/rooms/documents/room-document-actions-menu.tsx b/apps/web/src/features/rooms/documents/room-document-actions-menu.tsx
index d4a0783a..c62acfc7 100644
--- a/apps/web/src/features/rooms/documents/room-document-actions-menu.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-actions-menu.tsx
@@ -10,6 +10,11 @@ import {
import { Spinner } from "@/components/ui/spinner";
import { Icon } from "@/components/ui/icon";
import { ActionMenu } from "@/components/ui/action-menu";
+import { libraryMessages } from "@/features/library/library.messages";
+import { commonMessages } from "@/i18n/common.messages";
+import { useT } from "@/i18n/use-translation";
+
+import { documentPageMessages as m } from "./document-page.messages";
export interface RoomDocumentMenuActions {
busy?: boolean;
@@ -30,7 +35,7 @@ export interface RoomDocumentMenuActions {
export function DocumentActionsMenu({
actions,
contextOnly = false,
- label = "More Document actions",
+ label,
buttonClassName = "flex size-8 shrink-0 items-center justify-center rounded-sm text-app-muted hover:bg-app-hover hover:text-app-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-app-focus",
}: {
actions: RoomDocumentMenuActions;
@@ -38,6 +43,7 @@ export function DocumentActionsMenu({
label?: string;
buttonClassName?: string;
}) {
+ const t = useT();
const canExport = actions.canExport ?? actions.canUseVersion;
const canDuplicate = actions.canDuplicate ?? actions.canUseVersion;
const canDelete = actions.canDelete ?? true;
@@ -51,7 +57,7 @@ export function DocumentActionsMenu({
{
disabled: actions.busy,
icon: <Icon icon={Copy01Icon} size={14} />,
- label: "Copy link",
+ label: t(libraryMessages.copyLink),
onSelect: actions.onCopyLink,
},
...(actions.onRename
@@ -59,7 +65,7 @@ export function DocumentActionsMenu({
{
disabled: actions.busy || !actions.canRename,
icon: <Icon icon={PencilEdit01Icon} size={14} />,
- label: "Rename",
+ label: t(libraryMessages.rename),
onSelect: actions.onRename,
},
]
@@ -67,13 +73,13 @@ export function DocumentActionsMenu({
{
disabled: actions.busy || !canExport,
icon: <Icon icon={Download04Icon} size={14} />,
- label: "Download",
+ label: t(libraryMessages.download),
onSelect: actions.onExport,
},
{
disabled: actions.busy || !canDuplicate,
icon: <Icon icon={Copy01Icon} size={14} />,
- label: "Duplicate",
+ label: t(libraryMessages.duplicate),
onSelect: actions.onDuplicate,
},
]
@@ -83,7 +89,7 @@ export function DocumentActionsMenu({
{
disabled: actions.busy,
icon: <Icon icon={Clock04Icon} size={14} />,
- label: "Page history",
+ label: t(m.pageHistory),
onSelect: actions.onShowHistory,
},
]
@@ -93,7 +99,7 @@ export function DocumentActionsMenu({
{
disabled: actions.busy || !canDuplicate,
icon: <Icon icon={FolderTransferIcon} size={14} />,
- label: "Copy to My Documents",
+ label: t(libraryMessages.copyToMyDocuments),
onSelect: actions.onCopyToMyDocuments,
},
]
@@ -104,14 +110,15 @@ export function DocumentActionsMenu({
danger: true,
disabled: actions.busy || !canDelete,
icon: <Icon icon={Delete02Icon} size={14} />,
- label: "Delete",
+ label: t(commonMessages.delete),
onSelect: actions.onDelete,
separatorBefore: true,
+ voiceRisk: "never" as const,
},
]
: []),
]}
- label={label}
+ label={label ?? t(m.moreActions)}
trigger={
actions.busy ? (
<Spinner size={16} />
diff --git a/apps/web/src/features/rooms/documents/room-document-assets.ts b/apps/web/src/features/rooms/documents/room-document-assets.ts
index b1adb6a1..b4f0ae32 100644
--- a/apps/web/src/features/rooms/documents/room-document-assets.ts
+++ b/apps/web/src/features/rooms/documents/room-document-assets.ts
@@ -7,9 +7,11 @@ import { bytesToHex } from "@noble/hashes/utils.js";
import { idempotencyHeader, teamHubData } from "@/features/teamhub/teamhub-api";
import type { TeamHubClient } from "@/features/teamhub/teamhub-client";
+import { translate } from "@/i18n/language";
import documentAssetHashWorkerUrl from "./document-asset-hash-worker.ts?worker&url";
import { hashBlobIncrementally } from "./document-asset-hash";
+import { documentEditorMessages as m } from "./document-editor.messages";
import {
documentAssetHashTimeoutMs,
type DocumentAssetHashRequest,
@@ -62,14 +64,14 @@ export async function uploadRoomDocumentAsset(
blockId?: string,
): Promise<string> {
if (file.size < 1 || file.size > maxRoomDocumentAssetBytes) {
- throw new Error("Document Asset size is outside the supported range.");
+ throw new Error(translate(m.assetSizeUnsupported));
}
return roomDocumentAssetUploadGate.run(async () => {
const hashed = await hashDocumentAsset(file);
if (hashed.bytesRead !== file.size) {
throw new DocumentAssetUploadError(
"read",
- "Document Asset changed while it was being read.",
+ translate(m.assetChangedWhileReading),
);
}
const fileSha256 = hashed.sha256;
diff --git a/apps/web/src/features/rooms/documents/room-document-blocknote-editor-loader.tsx b/apps/web/src/features/rooms/documents/room-document-blocknote-editor-loader.tsx
index d8482827..990bca0f 100644
--- a/apps/web/src/features/rooms/documents/room-document-blocknote-editor-loader.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-blocknote-editor-loader.tsx
@@ -1,4 +1,8 @@
import { lazy, Suspense, useState } from "react";
+
+import { useT } from "@/i18n/use-translation";
+
+import { documentEditorMessages as m } from "./document-editor.messages";
import {
getPreloadedDocumentEditor,
preloadDocumentEditor,
@@ -15,6 +19,7 @@ const LazyRoomDocumentBlockNoteEditor = lazy(() =>
export function RoomDocumentBlockNoteEditor(
props: RoomDocumentBlockNoteEditorProps,
) {
+ const t = useT();
// Keep the selected component type for this mount: switching from lazy to
// direct after hydration would remount the editor and lose its selection.
const [Editor] = useState(
@@ -25,7 +30,7 @@ export function RoomDocumentBlockNoteEditor(
fallback={
<section
aria-busy="true"
- aria-label="Loading Room Document editor"
+ aria-label={t(m.loadingEditor)}
className="room-document-blocknote min-h-[420px]"
role="status"
/>
diff --git a/apps/web/src/features/rooms/documents/room-document-blocknote-editor.tsx b/apps/web/src/features/rooms/documents/room-document-blocknote-editor.tsx
index 42ad7155..28bb18fb 100644
--- a/apps/web/src/features/rooms/documents/room-document-blocknote-editor.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-blocknote-editor.tsx
@@ -4,6 +4,7 @@ import "./room-document-blocknote.css";
import "@/components/knowledge-document.css";
import { CommentsExtension } from "@blocknote/core/comments";
+import { zh } from "@blocknote/core/locales";
import { BlockNoteView } from "@blocknote/mantine";
import {
FilePanel,
@@ -28,6 +29,8 @@ import {
import { useNavigate } from "react-router";
import { teamHubData } from "@/features/teamhub/teamhub-api";
+import { translate } from "@/i18n/language";
+import { useT, useTranslation } from "@/i18n/use-translation";
import type { TeamHubClient } from "@/features/teamhub/teamhub-client";
import { collectTeamHubCursorPages } from "@/features/teamhub/teamhub-cursor-pages";
import { roomMembersQueryOptions } from "../room-queries";
@@ -89,6 +92,8 @@ import {
import { CanvasMailAttachments } from "./canvas/canvas-mail-attachments";
import { CanvasMailSentSync } from "./canvas/canvas-mail-send";
import { CanvasMailSender } from "./canvas/canvas-mail-sender";
+import { documentCommentsMessages } from "./document-comments.messages";
+import { documentEditorMessages as m } from "./document-editor.messages";
const ignoreCommentsOpenChange = () => undefined;
@@ -140,6 +145,7 @@ export function RoomDocumentBlockNoteEditor({
session,
tenantId,
}: RoomDocumentBlockNoteEditorProps) {
+ const { language, t } = useTranslation();
const navigate = useNavigate();
const openDocument = (path: string) => {
void navigate(path);
@@ -319,6 +325,8 @@ export function RoomDocumentBlockNoteEditor({
showCursorLabels: "always",
user: session.user,
},
+ // BlockNote's own menus and placeholders; English is its default.
+ ...(language === "zh-CN" ? { dictionary: zh } : {}),
extensions: [comments],
pasteHandler: ({ defaultPasteHandler, editor: target, event }) =>
pasteRoomDocumentRichHtml(target, event.clipboardData) ||
@@ -348,6 +356,7 @@ export function RoomDocumentBlockNoteEditor({
documentId,
imagePreviewStore,
editable,
+ language,
session,
],
);
@@ -392,7 +401,7 @@ export function RoomDocumentBlockNoteEditor({
return (
<section
ref={editorRootRef}
- aria-label="Room Document editor"
+ aria-label={t(m.editor)}
className="room-document-blocknote relative min-h-[420px]"
data-editable={String(editable)}
data-canvas-target={canvasTarget}
@@ -526,7 +535,7 @@ export function RoomDocumentBlockNoteEditor({
composer={
readOnlyCommentPending ? (
<DocumentMentionMessageComposer
- ariaLabel="New selection comment"
+ ariaLabel={t(documentCommentsMessages.newSelectionComment)}
// eslint-disable-next-line jsx-a11y/no-autofocus -- the field is focused on purpose because the user just opened this dialog or inline editor
autoFocus
mentionOptions={mentionOptions}
@@ -770,6 +779,7 @@ function lastCodePoints(value: string, limit: number): string {
}
function RoomDocumentFilePanel({ blockId }: FilePanelProps) {
+ const t = useT();
const editor = useBlockNoteEditor();
const components = useComponentsContext();
const uploading = useRef(false);
@@ -801,15 +811,11 @@ function RoomDocumentFilePanel({ blockId }: FilePanelProps) {
: result,
);
} catch {
- setUploadFailure(
- "The file was uploaded, but the Document block could not be updated. Try inserting it again.",
- );
+ setUploadFailure(translate(m.blockUpdateFailed));
}
} catch (error) {
setUploadFailure(
- error instanceof Error
- ? error.message
- : "Document Asset upload failed.",
+ error instanceof Error ? error.message : translate(m.uploadFailed),
);
} finally {
uploading.current = false;
@@ -820,7 +826,7 @@ function RoomDocumentFilePanel({ blockId }: FilePanelProps) {
blockId={blockId}
tabs={[
{
- name: "Upload",
+ name: t(m.upload),
tabPanel: (
<components.FilePanel.TabPanel className="bn-tab-panel">
<components.FilePanel.FileInput
@@ -828,7 +834,7 @@ function RoomDocumentFilePanel({ blockId }: FilePanelProps) {
className="bn-file-input"
data-test="upload-input"
onChange={(file) => void upload(file)}
- placeholder="Choose a file"
+ placeholder={t(m.chooseFile)}
value={null}
/>
{uploadFailure ? (
diff --git a/apps/web/src/features/rooms/documents/room-document-comment-agent-replying.tsx b/apps/web/src/features/rooms/documents/room-document-comment-agent-replying.tsx
index a15d722a..3788861b 100644
--- a/apps/web/src/features/rooms/documents/room-document-comment-agent-replying.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-comment-agent-replying.tsx
@@ -2,9 +2,11 @@ import type { ThreadData } from "@blocknote/core/comments";
import { useEffect, useState } from "react";
import type { TeamHubActorRef } from "@/features/teamhub/teamhub-types";
+import { useT } from "@/i18n/use-translation";
import { commentCompositionFromBody } from "./room-document-comment-body";
import { visibleThreadComments } from "./room-document-comments";
+import { documentCommentsMessages as m } from "./document-comments.messages";
/** Past this, an Agent that never answered stops showing as replying. */
export const AGENT_REPLY_WAIT_MS = 10 * 60 * 1000;
@@ -43,6 +45,7 @@ export function RoomDocumentCommentAgentReplying({
anchorText: string | null;
thread: ThreadData;
}) {
+ const t = useT();
const [now, setNow] = useState(() => Date.now());
const latest = visibleThreadComments(thread).at(-1);
// An Agent asked to change the anchored text edits the Document before it
@@ -72,8 +75,11 @@ export function RoomDocumentCommentAgentReplying({
const names = agents.map((agent) => agent.display_name);
const label =
names.length === 1
- ? `${names[0]} is replying`
- : `${names.slice(0, -1).join(", ")} and ${names.at(-1)} are replying`;
+ ? t(m.agentReplying, { name: names[0]! })
+ : t(m.agentsReplying, {
+ names: names.slice(0, -1).join(t(m.listSeparator)),
+ last: names.at(-1)!,
+ });
return (
<div aria-live="polite" className="agent-replying" role="status">
diff --git a/apps/web/src/features/rooms/documents/room-document-comment-composer.tsx b/apps/web/src/features/rooms/documents/room-document-comment-composer.tsx
index d8d0b411..0ff54546 100644
--- a/apps/web/src/features/rooms/documents/room-document-comment-composer.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-comment-composer.tsx
@@ -3,6 +3,7 @@ import { useBlockNoteEditor, useExtension } from "@blocknote/react";
import { useEffect, useRef } from "react";
import type { TeamHubActorRef } from "@/features/teamhub/teamhub-types";
+import { useT } from "@/i18n/use-translation";
import {
MessageComposer,
type MessageComposition,
@@ -10,6 +11,7 @@ import {
} from "../chat/message-composer";
import { commentBodyFromComposition } from "./room-document-comment-body";
+import { documentCommentsMessages as m } from "./document-comments.messages";
interface DocumentMentionComposerProps {
ariaLabel?: string;
@@ -48,7 +50,7 @@ export function RoomDocumentCommentComposer(
}
export function DocumentMentionMessageComposer({
- ariaLabel = "New Document comment",
+ ariaLabel,
autoFocus = false,
initialMentions,
initialValue,
@@ -58,12 +60,13 @@ export function DocumentMentionMessageComposer({
onCancel,
onSubmit,
onSubmitted,
- placeholder = "Add a comment",
+ placeholder,
submitLabel,
}: DocumentMentionComposerProps & {
onSubmit: (composition: MessageComposition) => Promise<void>;
onSubmitted?: () => void;
}) {
+ const t = useT();
const composerRef = useRef<MessageComposerHandle>(null);
useEffect(() => {
// Native autofocus runs before the anchored card is positioned and can
@@ -77,7 +80,7 @@ export function DocumentMentionMessageComposer({
className="room-document-comment-composer"
>
<MessageComposer
- ariaLabel={ariaLabel}
+ ariaLabel={ariaLabel ?? t(m.newComment)}
ref={composerRef}
documentMentionsEnabled={false}
initialMentions={initialMentions}
@@ -89,11 +92,11 @@ export function DocumentMentionMessageComposer({
await onSubmit(composition);
onSubmitted?.();
}}
- placeholder={placeholder}
+ placeholder={placeholder ?? t(m.addCommentPlaceholderShort)}
/>
{mentionDirectoryError ? (
<p className="mt-2 text-xs text-app-danger" role="alert">
- Mention directory is unavailable.
+ {t(m.mentionDirectoryUnavailable)}
</p>
) : null}
</div>
diff --git a/apps/web/src/features/rooms/documents/room-document-comment-reply-composer.tsx b/apps/web/src/features/rooms/documents/room-document-comment-reply-composer.tsx
index 7738c953..bfaa8cb9 100644
--- a/apps/web/src/features/rooms/documents/room-document-comment-reply-composer.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-comment-reply-composer.tsx
@@ -1,8 +1,10 @@
import type { TeamHubActorRef } from "@/features/teamhub/teamhub-types";
+import { useT } from "@/i18n/use-translation";
import { commentBodyFromComposition } from "./room-document-comment-body";
import { DocumentMentionMessageComposer } from "./room-document-comment-composer";
import type { TeamHubDocumentThreadStore } from "./room-document-comments";
+import { documentCommentsMessages as m } from "./document-comments.messages";
export function RoomDocumentCommentReplyComposer({
mentionOptions,
@@ -13,10 +15,11 @@ export function RoomDocumentCommentReplyComposer({
threadId: string;
threadStore: TeamHubDocumentThreadStore;
}) {
+ const t = useT();
return (
<div className="room-document-comment-reply">
<DocumentMentionMessageComposer
- ariaLabel="Reply to Document comment"
+ ariaLabel={t(m.replyToComment)}
mentionOptions={mentionOptions}
onSubmit={async (composition) => {
await threadStore.addComment({
@@ -24,7 +27,7 @@ export function RoomDocumentCommentReplyComposer({
threadId,
});
}}
- placeholder="Reply..."
+ placeholder={t(m.replyPlaceholder)}
/>
</div>
);
diff --git a/apps/web/src/features/rooms/documents/room-document-comment-row.tsx b/apps/web/src/features/rooms/documents/room-document-comment-row.tsx
index 7b67c657..72ccd50c 100644
--- a/apps/web/src/features/rooms/documents/room-document-comment-row.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-comment-row.tsx
@@ -6,6 +6,9 @@ import { useState } from "react";
import { Button } from "@/components/ui/button";
import type { TeamHubActorRef } from "@/features/teamhub/teamhub-types";
+import { commonMessages } from "@/i18n/common.messages";
+import { formatLocale, translate } from "@/i18n/language";
+import { useT, useTranslation } from "@/i18n/use-translation";
import { MessageMarkdown } from "../chat/message-markdown";
import { ActorAvatar } from "../members/actor-avatar";
@@ -15,6 +18,7 @@ import {
} from "./room-document-comment-body";
import type { TeamHubDocumentThreadStore } from "./room-document-comments";
import { DocumentMentionMessageComposer } from "./room-document-comment-composer";
+import { documentCommentsMessages as m } from "./document-comments.messages";
export function RoomDocumentCommentRow({
actors,
@@ -29,12 +33,13 @@ export function RoomDocumentCommentRow({
threadId: string;
threadStore: TeamHubDocumentThreadStore;
}) {
+ const { language, t } = useTranslation();
const [editing, setEditing] = useState(false);
const [error, setError] = useState<string>();
const author = (comment.metadata as { author?: TeamHubActorRef } | undefined)
?.author;
const actor = author ?? actors.get(comment.userId);
- const authorName = actor?.display_name || "Unknown author";
+ const authorName = actor?.display_name || t(m.unknownAuthor);
const composition = comment.body
? commentCompositionFromBody(comment.body, [
...actors.values(),
@@ -53,7 +58,7 @@ export function RoomDocumentCommentRow({
setEditing(false);
} catch (cause) {
setError(
- cause instanceof Error ? cause.message : "Comment action failed",
+ cause instanceof Error ? cause.message : translate(m.actionFailed),
);
}
}
@@ -70,16 +75,17 @@ export function RoomDocumentCommentRow({
<div className="room-document-comment-meta">
<strong title={authorName}>{authorName}</strong>
<time dateTime={comment.createdAt.toISOString()}>
- {formatDateTime(comment.createdAt, {
- day: "numeric",
- month: "short",
- })}
+ {formatDateTime(
+ comment.createdAt,
+ { day: "numeric", month: "short" },
+ formatLocale(language),
+ )}
</time>
</div>
{editing && composition ? (
<div className="room-document-comment-edit">
<DocumentMentionMessageComposer
- ariaLabel={`Edit comment by ${authorName}`}
+ ariaLabel={t(m.editCommentBy, { name: authorName })}
// eslint-disable-next-line jsx-a11y/no-autofocus -- the field is focused on purpose because the user just opened this dialog or inline editor
autoFocus
initialMentions={composition.mentions}
@@ -87,8 +93,8 @@ export function RoomDocumentCommentRow({
mentionOptions={mentionOptions}
onCancel={() => setEditing(false)}
onSubmit={(next) => save(commentBodyFromComposition(next))}
- placeholder="Edit comment"
- submitLabel="Confirm"
+ placeholder={t(m.editComment)}
+ submitLabel={t(m.confirm)}
/>
</div>
) : (
@@ -125,6 +131,7 @@ function CommentActions({
threadId: string;
threadStore: TeamHubDocumentThreadStore;
}) {
+ const t = useT();
const [error, setError] = useState<string>();
async function remove() {
@@ -133,7 +140,7 @@ function CommentActions({
await threadStore.deleteComment({ commentId: comment.id, threadId });
} catch (cause) {
setError(
- cause instanceof Error ? cause.message : "Comment action failed",
+ cause instanceof Error ? cause.message : translate(m.actionFailed),
);
}
}
@@ -143,13 +150,13 @@ function CommentActions({
<div className="room-document-comment-actions">
{threadStore.auth.canUpdateComment(comment) ? (
<Button
- aria-label="Edit comment"
+ aria-label={t(m.editComment)}
onClick={(event) => {
event.stopPropagation();
onEdit();
}}
size="compactIcon"
- title="Edit"
+ title={t(commonMessages.edit)}
tone="ghost"
>
<Icon icon={PencilEdit01Icon} size={14} />
@@ -157,10 +164,11 @@ function CommentActions({
) : null}
{threadStore.auth.canDeleteComment(comment) ? (
<Button
- aria-label="Delete comment"
+ aria-label={t(m.deleteComment)}
+ data-voice-risk="never"
onClick={() => void remove()}
size="compactIcon"
- title="Delete"
+ title={t(commonMessages.delete)}
tone="ghost"
>
<Icon icon={Delete02Icon} size={14} />
diff --git a/apps/web/src/features/rooms/documents/room-document-comment-thread.tsx b/apps/web/src/features/rooms/documents/room-document-comment-thread.tsx
index d9ea32b6..22096f6e 100644
--- a/apps/web/src/features/rooms/documents/room-document-comment-thread.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-comment-thread.tsx
@@ -6,6 +6,9 @@ import { useMemo, useState } from "react";
import { Button } from "@/components/ui/button";
import type { TeamHubActorRef } from "@/features/teamhub/teamhub-types";
+import { useT } from "@/i18n/use-translation";
+
+import { documentCommentsMessages as m } from "./document-comments.messages";
import { RoomDocumentCommentAgentReplying } from "./room-document-comment-agent-replying";
import { RoomDocumentCommentReplyComposer } from "./room-document-comment-reply-composer";
@@ -36,6 +39,7 @@ export function RoomDocumentCommentThread({
thread: ThreadData;
threadStore: TeamHubDocumentThreadStore;
}) {
+ const t = useT();
const actors = useMemo(
() => new Map(actorDirectory.map((actor) => [actor.id, actor])),
[actorDirectory],
@@ -63,7 +67,7 @@ export function RoomDocumentCommentThread({
// react-doctor-disable-next-line no-noninteractive-element-interactions
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- clicking the card selects its thread; the card controls stay keyboard accessible
<article
- aria-label={`Comment on ${referenceText}`}
+ aria-label={t(m.commentOn, { reference: referenceText })}
className="room-document-comment-thread"
data-anchor-pos={anchorPosition}
data-comment-card={thread.id}
@@ -99,11 +103,11 @@ export function RoomDocumentCommentThread({
className="room-document-comment-reference"
onClick={onFocus}
type="button"
- title={orphaned ? "Deleted reference" : referenceText}
+ title={orphaned ? t(m.deletedReference) : referenceText}
disabled={orphaned || selectionPending}
>
<Icon icon={QuoteDownIcon} size={14} />
- <span>{orphaned ? "Deleted reference" : referenceText}</span>
+ <span>{orphaned ? t(m.deletedReference) : referenceText}</span>
</button>
</header>
@@ -126,9 +130,7 @@ export function RoomDocumentCommentThread({
/>
{selectionPending && metadata?.attachmentError ? (
<div className="mt-2" role="alert">
- <p className="text-xs text-app-danger">
- Comment saved, but it couldn't be linked to the selected text.
- </p>
+ <p className="text-xs text-app-danger">{t(m.linkFailed)}</p>
<Button
className="mt-2"
disabled={attachmentPending}
@@ -137,7 +139,7 @@ export function RoomDocumentCommentThread({
tone="secondary"
>
<Icon icon={RotateLeft01Icon} size={14} />
- {attachmentPending ? "Retrying..." : "Retry linking"}
+ {attachmentPending ? t(m.retrying) : t(m.retryLinking)}
</Button>
</div>
) : null}
diff --git a/apps/web/src/features/rooms/documents/room-document-comments-sidebar.tsx b/apps/web/src/features/rooms/documents/room-document-comments-sidebar.tsx
index 40d93b38..2955285d 100644
--- a/apps/web/src/features/rooms/documents/room-document-comments-sidebar.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-comments-sidebar.tsx
@@ -27,7 +27,11 @@ import { createPortal } from "react-dom";
import { Button } from "@/components/ui/button";
import type { TeamHubActorRef } from "@/features/teamhub/teamhub-types";
+import { commonMessages } from "@/i18n/common.messages";
+import type { Translate } from "@/i18n/language";
+import { useT } from "@/i18n/use-translation";
+import { documentCommentsMessages as m } from "./document-comments.messages";
import { scrollDocumentPaneIndependently } from "./room-document-scroll";
import { resolveCommentAnchorPosition } from "./room-document-comment-position";
import { useAnchoredCommentLane } from "./room-document-comment-anchoring";
@@ -90,6 +94,7 @@ export function RoomDocumentCommentsController({
showTrigger?: boolean;
threadStore: TeamHubDocumentThreadStore;
}) {
+ const t = useT();
const comments = useExtension(CommentsExtension);
const threads = useThreads();
const { selectedThreadId, pendingComment } =
@@ -120,16 +125,17 @@ export function RoomDocumentCommentsController({
const panel = open ? (
<aside
- aria-label="All Document comments"
+ aria-label={t(m.allComments)}
className="room-document-comments-popover"
>
<div className="room-document-comments-heading">
- <h3>Comments</h3>
+ <h3>{t(m.comments)}</h3>
<Button
- aria-label="Close comments"
+ aria-label={t(m.closeComments)}
+ data-voice-close
onClick={() => setOpen(false)}
size="compactIcon"
- title="Close comments"
+ title={t(m.closeComments)}
tone="ghost"
>
<Icon icon={Cancel01Icon} size={14} />
@@ -141,9 +147,7 @@ export function RoomDocumentCommentsController({
>
{error ? (
<div className="px-4 py-8 text-center" role="alert">
- <p className="text-sm text-app-danger">
- Comments could not be loaded.
- </p>
+ <p className="text-sm text-app-danger">{t(m.loadFailed)}</p>
{onRetry ? (
<Button
className="mt-3"
@@ -152,7 +156,7 @@ export function RoomDocumentCommentsController({
tone="secondary"
>
<Icon icon={RotateLeft01Icon} size={14} />
- Retry
+ {t(commonMessages.retry)}
</Button>
) : null}
</div>
@@ -177,7 +181,7 @@ export function RoomDocumentCommentsController({
{showTrigger && threads.size > 0 ? (
<button
aria-expanded={open}
- aria-label={`Show all Document comments (${threads.size})`}
+ aria-label={t(m.showAllComments, { count: threads.size })}
className="room-document-comments-trigger"
onClick={() => {
comments.selectThread(undefined, false);
@@ -211,6 +215,7 @@ export function RoomDocumentCommentsList({
resolved?: boolean;
threadStore: TeamHubDocumentThreadStore;
}) {
+ const t = useT();
const editor = useBlockNoteEditor();
const listRef = useRef<HTMLDivElement>(null);
const composerRef = useRef<HTMLDivElement>(null);
@@ -329,7 +334,9 @@ export function RoomDocumentCommentsList({
<Icon icon={QuoteDownIcon} size={14} />
<span>
{pendingAnchor?.quoted_text ??
- (selection ? getReferenceText(editor, selection) : "Selected text")}
+ (selection
+ ? getReferenceText(editor, selection)
+ : t(m.selectedText))}
</span>
</div>
{composer}
@@ -389,7 +396,7 @@ export function RoomDocumentCommentsList({
orphaned={orphaned}
referenceText={
position === undefined
- ? anchorQuote(thread)
+ ? anchorQuote(thread, t)
: getReferenceText(editor, position)
}
selected={thread.id === selectedThreadId}
@@ -411,11 +418,11 @@ export function RoomDocumentCommentsList({
{ordered.length === 0 && !composer ? (
<div className="px-4 py-8 text-center">
<p className="text-sm text-app-muted">
- {resolved ? "No resolved comments" : "No open comments"}
+ {resolved ? t(m.noResolvedComments) : t(m.noOpenComments)}
</p>
{!resolved ? (
<p className="mx-auto mt-2 max-w-56 text-xs leading-5 text-app-subtle">
- Select text in the document, then choose Add comment.
+ {t(m.selectTextHint)}
</p>
) : null}
</div>
@@ -425,10 +432,10 @@ export function RoomDocumentCommentsList({
);
}
-function anchorQuote(thread: ThreadData): string {
+function anchorQuote(thread: ThreadData, t: Translate): string {
const anchor = (thread.metadata as { anchor?: { quoted_text?: unknown } })
.anchor;
return typeof anchor?.quoted_text === "string"
? anchor.quoted_text
- : "Deleted reference";
+ : t(m.deletedReference);
}
diff --git a/apps/web/src/features/rooms/documents/room-document-comments.ts b/apps/web/src/features/rooms/documents/room-document-comments.ts
index dec76c95..e6a9265e 100644
--- a/apps/web/src/features/rooms/documents/room-document-comments.ts
+++ b/apps/web/src/features/rooms/documents/room-document-comments.ts
@@ -19,6 +19,9 @@ import type {
import { collectTeamHubCursorPages } from "@/features/teamhub/teamhub-cursor-pages";
import { roomDocumentCommentThreadsQueryKey } from "../room-queries";
+import { translate } from "@/i18n/language";
+
+import { documentCommentsMessages as m } from "./document-comments.messages";
export type RoomDocumentCommentAnchor = TeamHubDocumentCommentAnchorInput;
@@ -336,7 +339,7 @@ export class TeamHubDocumentThreadStore extends ThreadStore {
#requireDurableHead(): TeamHubDocumentCommentDurableHead {
const head = this.#getDurableHead();
if (head === undefined) {
- throw new Error("Save the Document before creating or editing Comments");
+ throw new Error(translate(m.saveBeforeCommenting));
}
return head;
}
diff --git a/apps/web/src/features/rooms/documents/room-document-image-preview.tsx b/apps/web/src/features/rooms/documents/room-document-image-preview.tsx
index 23674ef9..ee545d79 100644
--- a/apps/web/src/features/rooms/documents/room-document-image-preview.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-image-preview.tsx
@@ -5,6 +5,9 @@ import {
imageParse,
} from "@blocknote/core";
+import { translate } from "@/i18n/language";
+
+import { documentEditorMessages as m } from "./document-editor.messages";
import type {
RoomDocumentEditor,
RoomDocumentPartialBlock,
@@ -262,14 +265,14 @@ const roomDocumentImageRender: typeof defaultImageRender = function (
const wrapper = document.createElement("div");
wrapper.className = "bn-visual-media-wrapper relative";
- const filename = block.props.name || preview?.filename || "image";
+ const filename = block.props.name || preview?.filename || translate(m.image);
const status = document.createElement("span");
status.className =
"inline-flex min-h-24 w-full items-center justify-center text-sm text-app-muted";
status.setAttribute("role", "status");
status.textContent = preview
- ? `Uploading ${filename}`
- : `Loading ${filename}`;
+ ? translate(m.uploadingFile, { filename })
+ : translate(m.loadingFile, { filename });
const image = document.createElement("img");
image.alt = filename;
@@ -292,7 +295,7 @@ const roomDocumentImageRender: typeof defaultImageRender = function (
})
.catch(() => {
status.setAttribute("role", "alert");
- status.textContent = `${filename} is unavailable`;
+ status.textContent = translate(m.fileUnavailable, { filename });
});
}
return { dom: wrapper };
diff --git a/apps/web/src/features/rooms/documents/room-document-mermaid-code-block.ts b/apps/web/src/features/rooms/documents/room-document-mermaid-code-block.ts
index 95d1eb36..72af87ee 100644
--- a/apps/web/src/features/rooms/documents/room-document-mermaid-code-block.ts
+++ b/apps/web/src/features/rooms/documents/room-document-mermaid-code-block.ts
@@ -7,10 +7,13 @@ import { createElement } from "react";
import { createRoot, type Root } from "react-dom/client";
import "./room-document-mermaid-code-block.css";
+import { commonMessages } from "@/i18n/common.messages";
+import { translate } from "@/i18n/language";
import { writeClipboardText } from "@/lib/clipboard";
import { renderMermaidSvg } from "../mermaid-preview-adapter";
import { MermaidSvgPreview } from "../mermaid-svg-preview";
+import { documentEditorMessages as m } from "./document-editor.messages";
/**
* Languages a Document can carry. Pasted source keeps its own label instead of
@@ -121,9 +124,9 @@ function renderRoomDocumentCodeBlock(
const language = document.createElement("span");
language.className = "room-document-mermaid__language";
language.textContent = "Mermaid";
- const sourceButton = modeButton("Source", mode === "source");
- const previewButton = modeButton("Preview", mode === "preview");
- const copyButton = modeButton("Copy source", false);
+ const sourceButton = modeButton(translate(m.source), mode === "source");
+ const previewButton = modeButton(translate(m.preview), mode === "preview");
+ const copyButton = modeButton(translate(m.copySource), false);
copyButton.classList.add("room-document-mermaid__copy");
copyButton.removeAttribute("aria-pressed");
const modes = document.createElement("div");
@@ -192,14 +195,14 @@ function renderRoomDocumentCodeBlock(
preview.dataset.renderVersion = String(++renderVersion);
renderedMermaidSource = mermaidSource;
previewRoot.render(
- createElement("p", null, "Add Mermaid source to see the diagram."),
+ createElement("p", null, translate(m.addMermaidSource)),
);
return;
}
if (mermaidSource === undefined) {
if (mode === "preview") {
previewRoot.render(
- createElement("p", null, "Mermaid source is unavailable."),
+ createElement("p", null, translate(m.mermaidSourceUnavailable)),
);
preview.hidden = false;
source.hidden = true;
@@ -233,14 +236,14 @@ function renderRoomDocumentCodeBlock(
const copySource = () => {
void writeClipboardText(currentCodeBlockSource())
.then(() => {
- copyButton.textContent = "Copied";
+ copyButton.textContent = translate(commonMessages.copied);
})
.catch(() => {
- copyButton.textContent = "Select source to copy";
+ copyButton.textContent = translate(m.selectSourceToCopy);
})
.finally(() => {
window.setTimeout(() => {
- copyButton.textContent = "Copy source";
+ copyButton.textContent = translate(m.copySource);
}, 1_500);
});
};
@@ -359,7 +362,7 @@ async function renderMermaidPreview(
createElement(MermaidSvgPreview, {
key: version,
svg: sanitized,
- title: "Mermaid diagram preview",
+ title: translate(m.mermaidPreview),
fitContent: true,
onLoad: () => {
if (!signal.aborted && version === currentRenderVersion(host))
@@ -372,8 +375,8 @@ async function renderMermaidPreview(
if (version !== currentRenderVersion(host)) return;
const message =
error instanceof Error
- ? `Mermaid syntax error: ${error.message}`
- : "Mermaid syntax error.";
+ ? translate(m.mermaidSyntaxError, { message: error.message })
+ : translate(m.mermaidSyntaxErrorPlain);
root.render(
createElement(
"p",
diff --git a/apps/web/src/features/rooms/documents/room-document-presence-model.ts b/apps/web/src/features/rooms/documents/room-document-presence-model.ts
index 47f6adf0..c841cfd7 100644
--- a/apps/web/src/features/rooms/documents/room-document-presence-model.ts
+++ b/apps/web/src/features/rooms/documents/room-document-presence-model.ts
@@ -1,5 +1,7 @@
import type { TeamHubRoomMember } from "@/features/teamhub/teamhub-types";
+import { translate } from "@/i18n/language";
+import { documentPageMessages as m } from "./document-page.messages";
import type { RoomDocumentCollaborationSession } from "./room-document-collaboration";
export type RoomDocumentAwareness = NonNullable<
@@ -84,7 +86,7 @@ export function createRoomDocumentCursor(
(actorId ? namesByActorId.get(actorId) : undefined) ??
presence?.name ??
actorId ??
- "Collaborator";
+ translate(m.collaborator);
const cursor = document.createElement("span");
cursor.classList.add("bn-collaboration-cursor__base");
cursor.setAttribute("data-active", "");
@@ -98,7 +100,7 @@ export function createRoomDocumentCursor(
const label = document.createElement("span");
label.classList.add("bn-collaboration-cursor__label");
- label.setAttribute("aria-label", `${name} cursor`);
+ label.setAttribute("aria-label", translate(m.cursor, { name }));
label.setAttribute("data-collaborator-name", name);
label.setAttribute("role", "img");
label.style.backgroundColor = color;
@@ -149,7 +151,7 @@ export function refreshRoomDocumentCursorName(
".bn-collaboration-cursor__label",
);
if (name === undefined || label === null) return;
- label.setAttribute("aria-label", `${name} cursor`);
+ label.setAttribute("aria-label", translate(m.cursor, { name }));
label.dataset.collaboratorName = name;
}
diff --git a/apps/web/src/features/rooms/documents/room-document-presence.tsx b/apps/web/src/features/rooms/documents/room-document-presence.tsx
index 29d1cb49..3b9ee750 100644
--- a/apps/web/src/features/rooms/documents/room-document-presence.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-presence.tsx
@@ -2,6 +2,9 @@ import { useCallback, useMemo, useSyncExternalStore } from "react";
import { ActorAvatar } from "@/features/rooms/members/actor-avatar";
import type { TeamHubRoomMember } from "@/features/teamhub/teamhub-types";
+import { useT } from "@/i18n/use-translation";
+
+import { documentPageMessages as m } from "./document-page.messages";
import type { RoomDocumentCollaborationSession } from "./room-document-collaboration";
import {
@@ -21,6 +24,7 @@ export function RoomDocumentPresence({
members: readonly TeamHubRoomMember[] | undefined;
showSelf?: boolean;
}) {
+ const t = useT();
const subscribe = useCallback(
(listener: () => void) => {
if (awareness === null) return () => undefined;
@@ -78,26 +82,37 @@ export function RoomDocumentPresence({
if (participants.length < 2 && !showSelf) return null;
const visibleParticipants = participants.slice(0, 5);
- const names = participants.map((participant) => participant.name).join(", ");
+ const names = participants
+ .map((participant) => participant.name)
+ .join(t(m.listSeparator));
const membersByActorId = new Map(
members?.map((member) => [member.actor.id, member.actor]),
);
return (
<span
- aria-label={`${participants.length} people in this document: ${names}`}
+ aria-label={t(m.peopleInDocument, {
+ count: participants.length,
+ names,
+ })}
aria-live="polite"
className="inline-flex min-w-0 shrink-0 items-center"
role="status"
>
- <span className="sr-only">{participants.length} people viewing</span>
+ <span className="sr-only">
+ {t(m.peopleViewing, { count: participants.length })}
+ </span>
<span className="flex -space-x-[5px] rounded-full p-1">
{visibleParticipants.map((participant) => (
<span
className="relative rounded-full border bg-app-surface p-px"
key={participant.actorId}
style={{ borderColor: participant.color }}
- title={`${participant.name}${participant.isCurrent ? " (you)" : ""}`}
+ title={
+ participant.isCurrent
+ ? t(m.nameYou, { name: participant.name })
+ : participant.name
+ }
>
<ActorAvatar
actorId={participant.actorId}
diff --git a/apps/web/src/features/rooms/documents/room-document-readonly-comment-control.tsx b/apps/web/src/features/rooms/documents/room-document-readonly-comment-control.tsx
index fc966c87..bf420e60 100644
--- a/apps/web/src/features/rooms/documents/room-document-readonly-comment-control.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-readonly-comment-control.tsx
@@ -3,7 +3,9 @@ import { Icon } from "@/components/ui/icon";
import { useEffect, useState, type MutableRefObject } from "react";
import { Button } from "@/components/ui/button";
+import { useT } from "@/i18n/use-translation";
+import { documentCommentsMessages as m } from "./document-comments.messages";
import { type RoomDocumentCommentAnchor } from "./room-document-comments";
import { readOnlyDocumentCommentAnchor } from "./room-document-readonly-selection";
@@ -20,6 +22,7 @@ export function ReadOnlySelectionCommentControl({
editorRootRef: MutableRefObject<HTMLElement | null>;
onStartComment: () => void;
}) {
+ const t = useT();
const [anchor, setAnchor] = useState<RoomDocumentCommentAnchor | null>(null);
const [position, setPosition] = useState<{
left: number;
@@ -95,12 +98,12 @@ export function ReadOnlySelectionCommentControl({
style={position}
>
<Button
- aria-label="Add comment to selected text"
+ aria-label={t(m.addCommentToSelection)}
onMouseDown={(event) => event.preventDefault()}
onClick={onStartComment}
className="bg-app-hover text-app-ink"
size="compactIcon"
- title="Add comment"
+ title={t(m.addComment)}
tone="ghost"
type="button"
>
diff --git a/apps/web/src/features/rooms/documents/room-document-slash-menu.tsx b/apps/web/src/features/rooms/documents/room-document-slash-menu.tsx
index ddf286d7..68453a7b 100644
--- a/apps/web/src/features/rooms/documents/room-document-slash-menu.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-slash-menu.tsx
@@ -8,6 +8,9 @@ import {
} from "@blocknote/react";
import { WorkflowSquare01Icon } from "@hugeicons/core-free-icons";
import { Icon } from "@/components/ui/icon";
+import { translate } from "@/i18n/language";
+
+import { documentEditorMessages as m } from "./document-editor.messages";
import { insertTableCellList } from "./room-document-table-list";
import type { RoomDocumentEditor } from "./room-document-blocknote-editor";
@@ -33,15 +36,15 @@ export function getRoomDocumentSlashMenuItems(
}),
{
aliases: ["diagram", "graph", "mmd"],
- group: "Other",
+ group: translate(m.slashGroupOther),
icon: <Icon icon={WorkflowSquare01Icon} />,
onItemClick: () =>
insertOrUpdateBlockForSlashMenu(editor, {
props: { language: "mermaid" },
type: "codeBlock",
}),
- subtext: "Create an editable Mermaid diagram",
- title: "Mermaid diagram",
+ subtext: translate(m.mermaidSubtext),
+ title: translate(m.mermaidTitle),
},
];
}
diff --git a/apps/web/src/features/rooms/documents/room-document-surface.tsx b/apps/web/src/features/rooms/documents/room-document-surface.tsx
index fc84e236..6031f76f 100644
--- a/apps/web/src/features/rooms/documents/room-document-surface.tsx
+++ b/apps/web/src/features/rooms/documents/room-document-surface.tsx
@@ -22,9 +22,12 @@ import { documentLogicalTitle } from "@/features/library/document-display-name";
import { useWikiDocumentLinks } from "@/features/wiki/wiki-document-links";
import type { TeamHubClient } from "@/features/teamhub/teamhub-client";
import type { TeamHubDocument } from "@/features/teamhub/teamhub-types";
+import { libraryMessages } from "@/features/library/library.messages";
+import { useT } from "@/i18n/use-translation";
import { DocumentVersionSelectionCommentControl } from "./document-version-selection-comment-control";
import { DocumentShareDialog } from "./document-share-dialog";
+import { documentPageMessages as m } from "./document-page.messages";
import { UnifiedDocumentBody } from "./unified-document-body";
import { UnifiedDocumentPageHeader } from "./unified-document-header";
import {
@@ -280,6 +283,7 @@ function UnifiedDocumentPageDialogs({
trashError: string | null;
trashPending: boolean;
}) {
+ const t = useT();
return (
<>
{historyOpen ? (
@@ -290,7 +294,7 @@ function UnifiedDocumentPageDialogs({
role="status"
>
<Spinner size={16} />
- Loading history…
+ {t(libraryMessages.loadingHistory)}
</div>
}
>
@@ -345,6 +349,7 @@ function UnifiedDocumentCommentsSurface({
rootRef: MutableRefObject<HTMLDivElement | null>;
tenantId: string;
}) {
+ const t = useT();
const [versionSelection, setVersionSelection] = useState<string | null>(null);
const [commentsMounted, setCommentsMounted] = useState(false);
useEffect(() => {
@@ -389,7 +394,7 @@ function UnifiedDocumentCommentsSurface({
{commentsOpen ? (
<div
{...commentsWidth.handleProps}
- aria-label="Resize Document comments"
+ aria-label={t(m.resizeComments)}
className={`${commentsWidth.handleProps.className} document-comments-resize-handle`}
/>
) : null}
diff --git a/apps/web/src/features/rooms/documents/unified-document-body.tsx b/apps/web/src/features/rooms/documents/unified-document-body.tsx
index 1e4b4f3a..8be2762e 100644
--- a/apps/web/src/features/rooms/documents/unified-document-body.tsx
+++ b/apps/web/src/features/rooms/documents/unified-document-body.tsx
@@ -16,8 +16,10 @@ import { teamHubData } from "@/features/teamhub/teamhub-api";
import type { TeamHubClient } from "@/features/teamhub/teamhub-client";
import type { useTeamHubRuntime } from "@/features/teamhub/teamhub-runtime";
import type { TeamHubDocument } from "@/features/teamhub/teamhub-types";
+import { useT } from "@/i18n/use-translation";
import { documentQueryKey } from "../room-queries";
+import { documentPageMessages as m } from "./document-page.messages";
import { DocumentVersionPreview } from "./document-version-preview";
import { EditableDocumentTitle } from "./editable-document-title";
import { RoomDocumentBlockNoteEditor } from "./room-document-blocknote-editor-loader";
@@ -47,6 +49,7 @@ export function UnifiedDocumentBody({
model,
wikiLinks,
}: UnifiedDocumentBodyProps) {
+ const t = useT();
const {
actor,
client,
@@ -74,7 +77,7 @@ export function UnifiedDocumentBody({
/>
{wikiLinks.pending ? (
<p className="px-6 py-2 text-sm text-app-muted" role="status">
- Opening Wiki page...
+ {t(m.openingWikiPage)}
</p>
) : null}
{wikiLinks.error ? (
@@ -130,6 +133,7 @@ function UnifiedDocumentEditorLayout({
model,
session,
}: UnifiedDocumentEditorLayoutProps) {
+ const t = useT();
const {
autoFocusTitle,
client,
@@ -176,7 +180,7 @@ function UnifiedDocumentEditorLayout({
</div>
{knowledgeTitle === undefined && !mailCanvas ? (
<div className="room-document-content-lane mx-auto mb-8 flex min-h-8 flex-wrap items-center gap-2 text-sm text-app-muted">
- <span>By {document.owner.display_name}</span>
+ <span>{t(m.byOwner, { name: document.owner.display_name })}</span>
<span aria-hidden="true">·</span>
<RoomDocumentSaveIndicator
alwaysVisible
@@ -243,13 +247,14 @@ function DocumentStatusBanner({
}
function DocumentBodySkeleton() {
+ const t = useT();
return (
<div
- aria-label="Opening document"
+ aria-label={t(m.openingDocument)}
className="workspace-content mx-auto min-h-full w-full px-5 py-12"
role="status"
>
- <span className="sr-only">Opening document...</span>
+ <span className="sr-only">{t(m.openingDocumentStatus)}</span>
<div className="h-10 w-3/5 animate-pulse rounded-sm bg-muted motion-reduce:animate-none" />
<div className="mt-4 h-4 w-2/5 animate-pulse rounded-sm bg-muted motion-reduce:animate-none" />
<div className="mt-12 space-y-3">
@@ -334,6 +339,7 @@ function RoomDocumentRecoveryButton({
name: string;
session: RoomDocumentCollaborationSession;
}) {
+ const t = useT();
const save = useSyncExternalStore(
session.subscribeSaveState,
session.getSaveSnapshot,
@@ -344,15 +350,15 @@ function RoomDocumentRecoveryButton({
}
return (
<Button
- aria-label="Download recovery copy"
+ aria-label={t(m.downloadRecoveryCopy)}
onClick={() => {
void downloadRecoveryCopy(name, session.document);
}}
- title="Download recovery copy"
+ title={t(m.downloadRecoveryCopy)}
tone="ghost"
>
<Icon icon={Download04Icon} />
- Recovery copy
+ {t(m.recoveryCopy)}
</Button>
);
}
@@ -449,6 +455,7 @@ function RoomDocumentConnectionStatus({
onRetry(): void;
session: RoomDocumentCollaborationSession;
}) {
+ const t = useT();
const save = useSyncExternalStore(
session.subscribeSaveState,
session.getSaveSnapshot,
@@ -457,11 +464,11 @@ function RoomDocumentConnectionStatus({
if (save.status !== "Connection failed") return null;
return (
<div className="mb-3 flex items-center gap-2 text-sm text-app-danger">
- <span aria-label="Document connection status" role="status">
- Connection failed
+ <span aria-label={t(m.connectionStatus)} role="status">
+ {t(m.connectionFailed)}
</span>
<button className="underline" onClick={onRetry} type="button">
- Retry connection
+ {t(m.retryConnection)}
</button>
</div>
);
@@ -476,6 +483,7 @@ export function RoomDocumentSaveIndicator({
isEditing: boolean;
session: RoomDocumentCollaborationSession;
}) {
+ const t = useT();
const save = useSyncExternalStore(
session.subscribeSaveState,
session.getSaveSnapshot,
@@ -493,8 +501,8 @@ export function RoomDocumentSaveIndicator({
if (save.status === "Connection failed") return saveStatusProbe;
if (session.readOnly) {
return (
- <span aria-label="Document access mode" role="status">
- Read only
+ <span aria-label={t(m.accessMode)} role="status">
+ {t(m.readOnly)}
</span>
);
}
@@ -511,8 +519,8 @@ export function RoomDocumentSaveIndicator({
return (
<>
{saveStatusProbe}
- <span aria-label="Document save status" role="status">
- Saved
+ <span aria-label={t(m.saveStatus)} role="status">
+ {t(m.saved)}
</span>
</>
);
@@ -521,30 +529,30 @@ export function RoomDocumentSaveIndicator({
const indicator = save.protocolError
? {
icon: Alert02Icon,
- label: "Save protocol error",
+ label: t(m.saveProtocolError),
tone: "text-app-danger",
}
: save.status === "Offline pending"
? {
icon: CloudOffIcon,
- label: "Offline changes pending",
+ label: t(m.offlineChangesPending),
tone: "text-app-warning",
}
: save.status === "Offline"
? {
icon: CloudOffIcon,
- label: "Offline",
+ label: t(m.offline),
tone: "text-app-muted",
}
: save.status === "Connecting"
? {
icon: null,
- label: "Connecting...",
+ label: t(m.connecting),
tone: "text-app-muted",
}
: {
icon: null,
- label: "Saving...",
+ label: t(m.saving),
tone: "text-app-muted",
};
@@ -552,7 +560,7 @@ export function RoomDocumentSaveIndicator({
<>
{saveStatusProbe}
<p
- aria-label="Document save status"
+ aria-label={t(m.saveStatus)}
className={`mt-0.5 flex items-center gap-1 text-[12px] leading-4 ${indicator.tone}`}
role="status"
>
diff --git a/apps/web/src/features/rooms/documents/unified-document-header.tsx b/apps/web/src/features/rooms/documents/unified-document-header.tsx
index b20fe31e..d73494e0 100644
--- a/apps/web/src/features/rooms/documents/unified-document-header.tsx
+++ b/apps/web/src/features/rooms/documents/unified-document-header.tsx
@@ -31,11 +31,15 @@ import {
import { WORKSPACE_TREE_ID } from "@/features/library/workspace-tree";
import { writeDocumentLinkClipboard } from "@/features/rooms/files/document-clipboard-link";
import { documentDetailPath } from "@/features/rooms/files/document-detail-routes";
+import { libraryMessages } from "@/features/library/library.messages";
import type { TeamHubClient } from "@/features/teamhub/teamhub-client";
import type {
TeamHubDocument,
TeamHubDocumentPlacementNode,
} from "@/features/teamhub/teamhub-types";
+import { commonMessages } from "@/i18n/common.messages";
+import { translate, type Translate } from "@/i18n/language";
+import { useT } from "@/i18n/use-translation";
import { roomMembersQueryOptions } from "../room-queries";
import type { RoomDocumentCollaborationSession } from "./room-document-collaboration";
@@ -44,6 +48,7 @@ import { collaborationColor } from "./room-document-presence-model";
import { DocumentActionsMenu } from "./room-document-actions-menu";
import type { UnifiedDocumentPageModel } from "./use-unified-document-page-model";
import { MailCanvasStatus } from "./canvas/canvas-mail-status";
+import { documentPageMessages as m } from "./document-page.messages";
interface UnifiedDocumentPageHeaderProps {
documentContentRef: MutableRefObject<HTMLDivElement | null>;
@@ -103,7 +108,9 @@ export function UnifiedDocumentPageHeader({
void writeDocumentLinkClipboard({
documentId,
tenantId,
- title: document ? documentLogicalTitle(document) : "Document",
+ title: document
+ ? documentLogicalTitle(document)
+ : translate(m.document),
url: new URL(
documentDetailPath({ documentId, tenantId }),
window.location.origin,
@@ -222,6 +229,7 @@ function UnifiedDocumentHeader({
treeOpen: boolean;
tenantId: string;
}) {
+ const t = useT();
const rename = useDocumentRename(tenantId);
const actionsMenu =
document && !isWikiPage ? (
@@ -253,11 +261,11 @@ function UnifiedDocumentHeader({
<Button
aria-controls={WORKSPACE_TREE_ID}
aria-expanded={treeOpen}
- aria-label="Open Library pages"
+ aria-label={t(m.openLibraryPages)}
className="sm:hidden"
onClick={onOpenTree}
size="icon"
- title="Library pages"
+ title={t(m.libraryPages)}
tone="ghost"
>
<Icon icon={SidebarLeftIcon} />
@@ -267,7 +275,7 @@ function UnifiedDocumentHeader({
{mailCanvas ? (
<span className="flex items-center gap-2 text-sm font-medium text-app-ink">
<Icon icon={Mail01Icon} size={16} />
- Mail
+ {t(m.mail)}
</span>
) : document ? (
<div className="room-document-header-file">
@@ -287,7 +295,7 @@ function UnifiedDocumentHeader({
</div>
) : (
<span className="truncate text-sm font-semibold text-app-ink">
- {sidebar ? "" : "Document"}
+ {sidebar ? "" : t(m.document)}
</span>
)}
</div>
@@ -305,10 +313,10 @@ function UnifiedDocumentHeader({
) : null}
{document && !isWikiPage ? (
<Button
- aria-label="Share"
+ aria-label={t(m.share)}
size="compactIcon"
onClick={onShare}
- title="Share"
+ title={t(m.share)}
tone="ghost"
>
<Icon icon={Share08Icon} />
@@ -321,11 +329,11 @@ function UnifiedDocumentHeader({
document.capabilities.read &&
document.capabilities.comment ? (
<Button
- aria-label="Comments"
+ aria-label={t(m.comments)}
aria-pressed={commentsOpen}
onClick={onComments}
size="icon"
- title="Comments"
+ title={t(m.comments)}
tone="ghost"
>
<Icon icon={Comment01Icon} />
@@ -333,11 +341,11 @@ function UnifiedDocumentHeader({
) : null}
{!sidebar && !mailCanvas ? (
<Button
- aria-label="Table of contents"
+ aria-label={t(commonMessages.tableOfContents)}
aria-pressed={tocOpen}
onClick={onToc}
size="icon"
- title="Table of contents"
+ title={t(commonMessages.tableOfContents)}
tone="ghost"
>
<Icon icon={TableOfContentsIcon} />
@@ -379,6 +387,7 @@ function UnifiedDocumentBreadcrumb({
sharedDocument: boolean;
sharedItems: TeamHubDocumentPlacementNode[];
}) {
+ const t = useT();
const personalPlacement = items.find(
(item) => item.node_kind === "document" && item.document_id === document.id,
);
@@ -409,32 +418,37 @@ function UnifiedDocumentBreadcrumb({
}
const context = document.from[0];
const contextLabel =
- context?.label ??
- (context?.binding_kind === "room"
- ? "Room"
- : context?.binding_kind === "task"
- ? "Work Item"
- : context?.binding_kind === "wiki_page" ||
- context?.binding_kind === "wiki_source"
- ? "Wiki"
- : "Documents");
+ context?.label ?? documentContextLabel(context?.binding_kind, t);
return (
<DocumentBreadcrumb
ancestors={ancestors}
currentName={documentFileName(document)}
rootLabel={
personalPlacement
- ? "Owned by Me"
+ ? t(libraryMessages.ownedByMe)
: sharedDocument
- ? "Shared with me"
+ ? t(libraryMessages.sharedWithMe)
: placement === undefined
? contextLabel
- : "Owned by Me"
+ : t(libraryMessages.ownedByMe)
}
/>
);
}
+function documentContextLabel(
+ bindingKind: TeamHubDocument["from"][number]["binding_kind"] | undefined,
+ t: Translate,
+) {
+ return bindingKind === "room"
+ ? t(m.contextRoom)
+ : bindingKind === "task"
+ ? t(m.contextWorkItem)
+ : bindingKind === "wiki_page" || bindingKind === "wiki_source"
+ ? t(m.contextWiki)
+ : t(m.contextDocuments);
+}
+
function DocumentBreadcrumb<T extends { id: string; name: string }>({
ancestors,
currentName,
@@ -444,6 +458,7 @@ function DocumentBreadcrumb<T extends { id: string; name: string }>({
currentName: string;
rootLabel: string;
}) {
+ const t = useT();
const visible = ancestors.length > 2 ? ancestors.slice(-2) : ancestors;
const items = [
{ key: "root", label: rootLabel },
@@ -456,7 +471,7 @@ function DocumentBreadcrumb<T extends { id: string; name: string }>({
return (
<nav
- aria-label="Breadcrumb"
+ aria-label={t(m.breadcrumb)}
className="hidden min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm text-app-muted sm:flex"
>
{items.map((item, index) => (
@@ -522,6 +537,7 @@ function RoomDocumentActions({
onEditingChange: (editing: boolean) => void;
session: RoomDocumentCollaborationSession;
}) {
+ const t = useT();
const save = useSyncExternalStore(
session.subscribeSaveState,
session.getSaveSnapshot,
@@ -533,12 +549,16 @@ function RoomDocumentActions({
buttonClassName="room-document-mode-trigger"
initialFocusIndex={isEditing ? 0 : 1}
itemClassName="flex min-h-9 w-full items-center gap-2 rounded px-2.5 py-1.5 text-left text-sm outline-none hover:bg-app-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-app-focus disabled:pointer-events-none disabled:opacity-45"
- label="Document mode"
+ label={t(m.documentMode)}
items={[
{
- label: "Edit",
+ label: t(commonMessages.edit),
icon: isEditing ? (
- <span aria-label="Current mode" className="inline-flex" role="img">
+ <span
+ aria-label={t(m.currentMode)}
+ className="inline-flex"
+ role="img"
+ >
<Icon icon={Tick02Icon} size={14} />
</span>
) : (
@@ -548,9 +568,13 @@ function RoomDocumentActions({
onSelect: () => onEditingChange(true),
},
{
- label: "Read",
+ label: t(m.read),
icon: !isEditing ? (
- <span aria-label="Current mode" className="inline-flex" role="img">
+ <span
+ aria-label={t(m.currentMode)}
+ className="inline-flex"
+ role="img"
+ >
<Icon icon={Tick02Icon} size={14} />
</span>
) : (
@@ -561,7 +585,7 @@ function RoomDocumentActions({
]}
trigger={
<>
- <span>{isEditing ? "Edit mode" : "Read mode"}</span>
+ <span>{isEditing ? t(m.editMode) : t(m.readMode)}</span>
<Icon icon={ArrowDown01Icon} size={14} />
</>
}
diff --git a/apps/web/src/features/rooms/documents/unified-document-timeline-dialog.tsx b/apps/web/src/features/rooms/documents/unified-document-timeline-dialog.tsx
index e35de1f9..7ffebcd9 100644
--- a/apps/web/src/features/rooms/documents/unified-document-timeline-dialog.tsx
+++ b/apps/web/src/features/rooms/documents/unified-document-timeline-dialog.tsx
@@ -1,4 +1,4 @@
-import { dateTimeFormat } from "@/lib/date-format";
+import { formatDateTime } from "@/lib/date-format";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
Cancel01Icon,
@@ -17,14 +17,17 @@ import { teamHubData } from "@/features/teamhub/teamhub-api";
import { documentQueryKey } from "@/features/rooms/room-queries";
import type { TeamHubDocumentHistoryEntry } from "@/features/teamhub/teamhub-types";
import { ActorAvatar } from "@/features/rooms/members/actor-avatar";
+import { formatLocale, translate, type Translate } from "@/i18n/language";
+import { useT, useTranslation } from "@/i18n/use-translation";
import { diffDocumentLines } from "./document-history-diff";
import { historyRevisionMarkdown } from "./document-history-revision";
+import { documentPageMessages as m } from "./document-page.messages";
-const dateFormatter = dateTimeFormat({
+const checkpointDate: Intl.DateTimeFormatOptions = {
dateStyle: "medium",
timeStyle: "short",
-});
+};
export function UnifiedDocumentTimelineDialog({
client,
@@ -37,6 +40,7 @@ export function UnifiedDocumentTimelineDialog({
onClose: () => void;
tenantId: string;
}) {
+ const t = useT();
const queryClient = useQueryClient();
const [selectedHistoryId, setSelectedHistoryId] = useState<string | null>(
null,
@@ -105,7 +109,9 @@ export function UnifiedDocumentTimelineDialog({
},
onSuccess: async (result) => {
setRestoreFeedback(
- result.status === "already_current" ? "Already current." : "Restored.",
+ result.status === "already_current"
+ ? translate(m.alreadyCurrent)
+ : translate(m.restored),
);
if (result.status === "restored") {
await Promise.all([
@@ -119,16 +125,19 @@ export function UnifiedDocumentTimelineDialog({
});
return (
<ModalDialog
- ariaLabel="Page history"
+ ariaLabel={t(m.pageHistory)}
className="fixed inset-0 z-50 m-0 max-h-none max-w-none overflow-hidden border-0 bg-popover p-0 shadow-lg backdrop:bg-[var(--app-overlay)] backdrop:backdrop-blur-sm sm:inset-0 sm:m-auto sm:h-[min(640px,82dvh)] sm:w-[calc(100%-2.5rem)] sm:max-w-3xl sm:rounded-lg"
onClose={onClose}
>
<div className="flex h-full min-h-0 flex-col">
<header className="flex min-h-14 shrink-0 items-center justify-between gap-3 border-b border-app-border px-4">
- <h2 className="text-sm font-semibold text-app-ink">Page history</h2>
+ <h2 className="text-sm font-semibold text-app-ink">
+ {t(m.pageHistory)}
+ </h2>
<div>
<Button
- aria-label="Close Page history"
+ aria-label={t(m.closePageHistory)}
+ data-voice-close
onClick={onClose}
size="icon"
tone="ghost"
@@ -141,7 +150,7 @@ export function UnifiedDocumentTimelineDialog({
<div className="grid h-full min-h-0 sm:grid-cols-[200px_minmax(0,1fr)]">
<aside className="workspace-scrollbar min-h-0 overflow-y-auto border-b border-app-border p-3 sm:border-r sm:border-b-0">
<TimelineList
- empty="No page history saved yet."
+ empty={t(m.noPageHistory)}
error={history.error}
items={history.data?.items ?? []}
onSelect={setSelectedHistoryId}
@@ -191,7 +200,7 @@ function useHistoryMarkdown(
}),
);
if (content.history_entry.id !== entry.id) {
- throw new Error("History Revision identity is inconsistent.");
+ throw new Error(translate(m.revisionInconsistent));
}
return historyRevisionMarkdown(
content.state_bytes,
@@ -229,19 +238,24 @@ function HistoryPreview({
restoreFeedback: string | null;
restorePending: boolean;
}) {
+ const { language, t } = useTranslation();
return (
<section
- aria-label="History preview"
+ aria-label={t(m.historyPreview)}
className="flex min-h-0 min-w-0 flex-col"
>
{entry ? (
<div className="flex min-h-12 shrink-0 items-center justify-between gap-3 border-b border-app-border px-4">
<div className="min-w-0">
<p className="truncate text-sm font-medium text-app-ink">
- {dateFormatter.format(new Date(entry.created_at))}
+ {formatDateTime(
+ entry.created_at,
+ checkpointDate,
+ formatLocale(language),
+ )}
</p>
<p className="truncate text-xs text-app-muted">
- {historyActors(entry)}
+ {historyActors(entry, t)}
</p>
</div>
{previousEntry ? (
@@ -253,7 +267,7 @@ function HistoryPreview({
}
type="checkbox"
/>
- Highlight changes
+ {t(m.highlightChanges)}
</label>
) : null}
</div>
@@ -261,7 +275,7 @@ function HistoryPreview({
<div className="workspace-scrollbar min-h-0 flex-1 overflow-y-auto">
{!entry ? (
<div className="flex h-full items-center justify-center p-8 text-center text-sm text-app-muted">
- Select a checkpoint to preview it.
+ {t(m.selectCheckpoint)}
</div>
) : loading ? (
<div
@@ -269,7 +283,7 @@ function HistoryPreview({
role="status"
>
<Spinner size={16} />
- Loading checkpoint...
+ {t(m.loadingCheckpoint)}
</div>
) : error ? (
<p className="p-8 text-center text-sm text-app-danger" role="alert">
@@ -280,7 +294,7 @@ function HistoryPreview({
) : markdown ? (
<div className="mx-auto max-w-[760px] px-6 py-8">
<ReadOnlyBlockNoteDocumentLoader
- ariaLabel="Historical Document content"
+ ariaLabel={t(m.historicalContent)}
markdown={markdown}
/>
</div>
@@ -289,10 +303,10 @@ function HistoryPreview({
{diff ? (
<span className="flex items-center gap-2">
<Icon icon={Tick02Icon} size={14} />
- This checkpoint is identical to the previous checkpoint.
+ {t(m.checkpointIdentical)}
</span>
) : (
- "This checkpoint has no content."
+ t(m.checkpointEmpty)
)}
</div>
)}
@@ -311,13 +325,18 @@ function HistoryPreview({
</p>
) : null}
</div>
- <Button disabled={restorePending} onClick={onRestore} tone="primary">
+ <Button
+ data-voice-risk="confirm"
+ disabled={restorePending}
+ onClick={onRestore}
+ tone="primary"
+ >
{restorePending ? (
<Spinner size={14} />
) : (
<Icon icon={RotateLeft01Icon} size={14} />
)}
- Restore checkpoint
+ {t(m.restoreCheckpoint)}
</Button>
</div>
) : null}
@@ -356,10 +375,10 @@ function HistoryDiff({
);
}
-function historyActors(entry: TeamHubDocumentHistoryEntry) {
+function historyActors(entry: TeamHubDocumentHistoryEntry, t: Translate) {
const actors =
entry.contributors.length > 0 ? entry.contributors : [entry.created_by];
- return actors.map((actor) => actor.display_name).join(", ");
+ return actors.map((actor) => actor.display_name).join(t(m.listSeparator));
}
function TimelineList({
@@ -377,6 +396,7 @@ function TimelineList({
pending: boolean;
selectedId?: string;
}) {
+ const { language, t } = useTranslation();
if (pending) {
return (
<p
@@ -384,7 +404,7 @@ function TimelineList({
role="status"
>
<Spinner size={16} />
- Loading timeline...
+ {t(m.loadingTimeline)}
</p>
);
}
@@ -419,7 +439,11 @@ function TimelineList({
/>
<span className="min-w-0">
<strong className="block truncate text-sm font-medium text-app-ink">
- {dateFormatter.format(new Date(item.created_at))}
+ {formatDateTime(
+ item.created_at,
+ checkpointDate,
+ formatLocale(language),
+ )}
</strong>
<span className="mt-0.5 block text-xs text-app-muted">
{item.created_by.display_name}
diff --git a/apps/web/src/features/rooms/documents/use-room-document-session.ts b/apps/web/src/features/rooms/documents/use-room-document-session.ts
index a5ce2f6e..99cfe3bd 100644
--- a/apps/web/src/features/rooms/documents/use-room-document-session.ts
+++ b/apps/web/src/features/rooms/documents/use-room-document-session.ts
@@ -22,12 +22,15 @@ import {
roomDocumentQueryKey,
teamHubIdentityQueryOptions,
} from "../room-queries";
+import { translate, type Translate } from "@/i18n/language";
+import { useT } from "@/i18n/use-translation";
import { artifactPreviewCache } from "../files/artifact-preview-cache";
import type { RoomDocumentCollaborationSession } from "./room-document-collaboration";
import { deleteRoomDocumentLocalCopies } from "./room-document-local-copies";
import { collaborationColor } from "./room-document-presence-model";
import { preloadDocumentEditor } from "./document-editor-preload";
+import { documentPageMessages as m } from "./document-page.messages";
export function useRoomDocumentSession({
client,
@@ -42,6 +45,7 @@ export function useRoomDocumentSession({
roomId?: string;
tenantId: string;
}) {
+ const t = useT();
const queryClient = useQueryClient();
const [session, setSession] =
useState<RoomDocumentCollaborationSession | null>(null);
@@ -370,12 +374,13 @@ export function useRoomDocumentSession({
document,
error:
documentId === undefined
- ? "Document metadata is unavailable."
+ ? t(m.metadataUnavailable)
: collaborationErrorMessage(
documentQuery.error ??
identityQuery.error ??
opening.error ??
openError,
+ t,
),
session,
resyncSession,
@@ -395,18 +400,19 @@ function validateRefreshedCredential(input: {
}
}
-function collaborationErrorMessage(error: unknown): string | undefined {
+function collaborationErrorMessage(
+ error: unknown,
+ t: Translate,
+): string | undefined {
if (error === undefined || error === null) return undefined;
if (
error instanceof TeamHubError &&
error.status === 404 &&
error.code === "NOT_FOUND"
) {
- return "Document is unavailable.";
+ return t(m.documentUnavailable);
}
- return error instanceof Error
- ? error.message
- : "Document collaboration could not be opened.";
+ return error instanceof Error ? error.message : t(m.collaborationOpenFailed);
}
function validateOpenInputs(input: {
@@ -421,7 +427,7 @@ function validateOpenInputs(input: {
expectedTenantId: string;
}): void {
if (input.documentStatus !== "active") {
- throw new Error("Document is unavailable.");
+ throw new Error(translate(m.documentUnavailable));
}
if (
input.documentId !== input.expectedDocumentId ||
diff --git a/apps/web/src/features/rooms/documents/use-unified-document-actions.ts b/apps/web/src/features/rooms/documents/use-unified-document-actions.ts
index afcfae66..52e5cfb7 100644
--- a/apps/web/src/features/rooms/documents/use-unified-document-actions.ts
+++ b/apps/web/src/features/rooms/documents/use-unified-document-actions.ts
@@ -11,6 +11,9 @@ import type {
TeamHubDocument,
TeamHubDocumentPlacementNode,
} from "@/features/teamhub/teamhub-types";
+import { translate } from "@/i18n/language";
+
+import { documentPageMessages as m } from "./document-page.messages";
interface UnifiedDocumentActionsInput {
client: TeamHubClient;
@@ -74,7 +77,7 @@ export function useUnifiedDocumentActions({
setTrashError(
trashDocumentError instanceof Error
? trashDocumentError.message
- : "The Document could not be moved to trash.",
+ : translate(m.trashFailed),
);
} finally {
setTrashPending(false);
@@ -96,7 +99,7 @@ export function useUnifiedDocumentActions({
setExportError(
exportDocumentError instanceof Error
? exportDocumentError.message
- : "The Document could not be exported.",
+ : translate(m.exportFailed),
);
} finally {
setExportPending(false);
@@ -125,7 +128,7 @@ export function useUnifiedDocumentActions({
setDocumentActionError(
duplicateError instanceof Error
? duplicateError.message
- : "The Document could not be duplicated.",
+ : translate(m.duplicateFailed),
);
} finally {
setDuplicatePending(false);
diff --git a/apps/web/src/i18n/locales/zh-CN.json b/apps/web/src/i18n/locales/zh-CN.json
index ddc3dc88..c0efaa9a 100644
--- a/apps/web/src/i18n/locales/zh-CN.json
+++ b/apps/web/src/i18n/locales/zh-CN.json
@@ -2888,6 +2888,213 @@
"attachmentUnavailable": "这个附件无法下载。",
"attachmentDownloadFailed": "无法下载附件。"
},
+ "documentComments": {
+ "allComments": "全部文档评论",
+ "comments": "评论",
+ "closeComments": "关闭评论",
+ "loadingComments": "正在加载评论…",
+ "loadFailed": "无法加载评论。",
+ "noComments": "没有评论",
+ "addComment": "添加评论",
+ "newComment": "新的文档评论",
+ "addCommentPlaceholder": "添加评论…",
+ "addFailed": "无法添加评论。",
+ "adding": "正在添加…",
+ "commentBy": "{name} 的评论",
+ "commentDeleted": "评论已删除",
+ "sendReply": "发送回复",
+ "replyToComment": "回复文档评论",
+ "reply": "回复",
+ "showAllComments": "显示全部文档评论({count})",
+ "selectedText": "选中的文字",
+ "noResolvedComments": "没有已解决的评论",
+ "noOpenComments": "没有未解决的评论",
+ "selectTextHint": "在文档中选中文字,然后选择“添加评论”。",
+ "deletedReference": "引用的内容已删除",
+ "commentOn": "评论“{reference}”",
+ "linkFailed": "评论已保存,但未能关联到选中的文字。",
+ "retrying": "正在重试…",
+ "retryLinking": "重新关联",
+ "unknownAuthor": "未知作者",
+ "actionFailed": "评论操作失败",
+ "editCommentBy": "编辑 {name} 的评论",
+ "editComment": "编辑评论",
+ "confirm": "确认",
+ "deleteComment": "删除评论",
+ "addCommentPlaceholderShort": "添加评论",
+ "replyPlaceholder": "回复…",
+ "mentionDirectoryUnavailable": "无法加载可提及的成员。",
+ "agentReplying": "{name} 正在回复",
+ "agentsReplying": "{names} 和 {last} 正在回复",
+ "listSeparator": "、",
+ "addCommentToSelection": "为选中的文字添加评论",
+ "saveBeforeCommenting": "请先保存文档,再添加或编辑评论",
+ "newSelectionComment": "新的选区评论"
+ },
+ "documentEditor": {
+ "editor": "Room 文档编辑器",
+ "loadingEditor": "正在加载 Room 文档编辑器",
+ "blockUpdateFailed": "文件已上传,但文档块未能更新。请重新插入。",
+ "uploadFailed": "文档资源上传失败。",
+ "assetSizeUnsupported": "文件大小超出支持的范围。",
+ "assetChangedWhileReading": "文件在读取过程中发生了变化。",
+ "upload": "上传",
+ "chooseFile": "选择文件",
+ "slashGroupOther": "其他",
+ "mermaidSubtext": "创建可编辑的 Mermaid 图表",
+ "mermaidTitle": "Mermaid 图表",
+ "uploadingFile": "正在上传 {filename}",
+ "loadingFile": "正在加载 {filename}",
+ "fileUnavailable": "{filename} 不可用",
+ "image": "图片",
+ "source": "源码",
+ "preview": "预览",
+ "copySource": "复制源码",
+ "selectSourceToCopy": "请选中源码后复制",
+ "addMermaidSource": "添加 Mermaid 源码后即可查看图表。",
+ "mermaidSourceUnavailable": "Mermaid 源码不可用。",
+ "mermaidPreview": "Mermaid 图表预览",
+ "mermaidSyntaxError": "Mermaid 语法错误:{message}",
+ "mermaidSyntaxErrorPlain": "Mermaid 语法错误。",
+ "loadingDocument": "正在加载文档…",
+ "embeddedMediaOmitted": "已省略嵌入的媒体。",
+ "showLess": "收起",
+ "viewMore": "查看更多"
+ },
+ "documentPage": {
+ "document": "文档",
+ "openLibraryPages": "打开资料库页面",
+ "libraryPages": "资料库页面",
+ "mail": "邮件",
+ "share": "分享",
+ "comments": "评论",
+ "breadcrumb": "路径",
+ "contextRoom": "Room",
+ "contextWorkItem": "工作项",
+ "contextWiki": "Wiki",
+ "contextDocuments": "文档",
+ "documentMode": "文档模式",
+ "read": "阅读",
+ "currentMode": "当前模式",
+ "editMode": "编辑模式",
+ "readMode": "阅读模式",
+ "moreActions": "更多文档操作",
+ "pageHistory": "页面历史",
+ "openingWikiPage": "正在打开 Wiki 页面…",
+ "byOwner": "作者:{name}",
+ "openingDocument": "正在打开文档",
+ "openingDocumentStatus": "正在打开文档…",
+ "downloadRecoveryCopy": "下载恢复副本",
+ "recoveryCopy": "恢复副本",
+ "connectionStatus": "文档连接状态",
+ "connectionFailed": "连接失败",
+ "retryConnection": "重新连接",
+ "accessMode": "文档访问模式",
+ "readOnly": "只读",
+ "saveStatus": "文档保存状态",
+ "saved": "已保存",
+ "saveProtocolError": "保存协议出错",
+ "offlineChangesPending": "离线更改待同步",
+ "offline": "离线",
+ "connecting": "正在连接…",
+ "saving": "正在保存…",
+ "titleUpdateFailed": "无法更新标题。",
+ "renameDocument": "重命名文档",
+ "documentTitle": "文档标题",
+ "trashFailed": "无法把文档移到回收站。",
+ "exportFailed": "无法导出文档。",
+ "duplicateFailed": "无法创建文档副本。",
+ "resizeComments": "调整文档评论宽度",
+ "closePageHistory": "关闭页面历史",
+ "noPageHistory": "还没有保存的页面历史。",
+ "loadingTimeline": "正在加载时间线…",
+ "historyPreview": "历史预览",
+ "highlightChanges": "突出显示更改",
+ "selectCheckpoint": "选择一个版本进行预览。",
+ "loadingCheckpoint": "正在加载版本…",
+ "historicalContent": "文档历史内容",
+ "checkpointIdentical": "这个版本与上一个版本相同。",
+ "checkpointEmpty": "这个版本没有内容。",
+ "restoreCheckpoint": "恢复此版本",
+ "alreadyCurrent": "已是当前版本。",
+ "restored": "已恢复。",
+ "revisionInconsistent": "历史修订的标识不一致。",
+ "revisionIntegrityFailed": "历史修订的数据未通过完整性校验。",
+ "revisionInvalid": "历史修订的数据无效。",
+ "listSeparator": "、",
+ "noPublishedVersion": "这个文档没有已发布的版本。",
+ "previewLoadFailed": "无法加载文档预览。",
+ "downloadFailed": "文档下载失败。",
+ "retryPreview": "重新加载预览",
+ "loadingPreview": "正在加载预览…",
+ "previewUnavailable": "这个版本无法预览。",
+ "metadataUnavailable": "文档元数据不可用。",
+ "documentUnavailable": "文档不可用。",
+ "collaborationOpenFailed": "无法打开文档协作。",
+ "peopleInDocument": "{count} 人在这个文档中:{names}",
+ "peopleViewing": {
+ "other": "{count} 人正在查看"
+ },
+ "nameYou": "{name}(你)",
+ "collaborator": "协作者",
+ "cursor": "{name} 的光标"
+ },
+ "documentShare": {
+ "shareDocument": "分享文档",
+ "backToShare": "返回分享",
+ "share": "分享",
+ "manageCollaborators": "管理协作者",
+ "yourAccess": "你的权限:{role}",
+ "settingsUnavailable": "分享设置不可用。",
+ "refresh": "刷新",
+ "changeStatus": "分享更改状态",
+ "savingAccess": "正在保存权限…",
+ "inviteCollaborators": "邀请协作者",
+ "manageActiveCollaborators": "管理 {count} 位协作者",
+ "activeCount": "{count} 位",
+ "agentsWithDirectAccess": "直接拥有权限的 Agent",
+ "agent": "Agent",
+ "person": "成员",
+ "permission": "{label} 的权限",
+ "removeAccess": "移除权限",
+ "noDirectCollaborators": "还没有直接添加的协作者。",
+ "removeTitle": "移除 {label}?",
+ "removeAccessBody": "将移除对方的直接权限。通过 Room、任务或 Wiki 获得的权限不受影响。",
+ "sharedWithRooms": "已分享到的 Room",
+ "removeFromRoom": "从 Room 移除",
+ "removeFromRoomTitle": "从 {label} 移除?",
+ "removeFromRoomBody": "Room 成员将无法再通过这个 Room 访问。直接权限以及通过任务和 Wiki 获得的权限不受影响。",
+ "documentLink": "文档链接",
+ "copyLinkHint": "复制链接不会改变谁能访问这个文档。",
+ "searchCollaborators": "搜索协作者",
+ "searchAgents": "搜索 Agent",
+ "addCollaborators": "添加协作者",
+ "loadingCollaborators": "正在加载协作者…",
+ "unableToLoad": "无法加载,点击重试",
+ "noMatchingCollaborators": "没有匹配的协作者。",
+ "selected": "已选择",
+ "select": "选择",
+ "inviteRole": "邀请角色",
+ "invite": "邀请",
+ "inviteCount": "邀请({count})",
+ "shareLoading": "正在加载分享设置",
+ "loadingAccess": "正在加载权限",
+ "linkCopyFailed": "无法复制文档链接。",
+ "inviteFailed": "部分协作者未能邀请成功。请刷新后重试。",
+ "removeFromRoomFailed": "无法把文档从这个 Room 中移除。请刷新后重试。",
+ "permissionUpdateFailed": "无法更新协作者权限。",
+ "removeCollaboratorFailed": "无法移除协作者。",
+ "linkUpdateFailed": "无法更新链接分享设置。",
+ "anyoneWithLink": "获得链接的任何人",
+ "linkAccess": "链接权限",
+ "linkDisabled": "已停用",
+ "canView": "可查看",
+ "canEdit": "可编辑",
+ "resetLink": "重置链接",
+ "copySharedLink": "复制分享链接",
+ "sharedLinkCopyFailed": "无法复制链接。",
+ "linkSharingUnavailable": "链接分享不可用。"
+ },
"filePreview": {
"noPublishedVersion": "这个文件还没有发布的版本。",
"previewLoadFailed": "无法加载文件预览。",