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 Pocket Notes panel
Kilyn221abbebc08f
diff --git a/apps/web/src/features/rooms/pocket-notes/pocket-note-editor.tsx b/apps/web/src/features/rooms/pocket-notes/pocket-note-editor.tsxindex e5548877..b747d9f0 100644--- a/apps/web/src/features/rooms/pocket-notes/pocket-note-editor.tsx+++ b/apps/web/src/features/rooms/pocket-notes/pocket-note-editor.tsx@@ -23,8 +23,11 @@ import {type Ref,} from "react";+import { useT } from "@/i18n/use-translation";import { cn } from "@/lib/cn";+import { pocketNotesMessages as m } from "./pocket-notes.messages";+// Each block remains one Markdown line, including empty lines and heading markers.const schema = new Schema({nodes: {@@ -76,6 +79,22 @@ function noteText(doc: ProseMirrorNode | Fragment) {return lines.join("\n");}+/** The page's own attributes; its name and placeholder follow the language. */+function pageAttributes(label: string, placeholder: string) {+ return {+ role: "textbox",+ "aria-label": label,+ "aria-multiline": "true",+ "data-placeholder": placeholder,+ class: cn(+ "min-h-full whitespace-pre-wrap [overflow-wrap:anywhere] outline-none [&>*]:m-0",+ "[&>:is(h1,h2,h3,h4,h5,h6)]:font-[580] [&>:is(h1,h2,h3,h4,h5,h6)]:leading-[1.4]",+ "[&>h1]:text-[24px] [&>h2]:text-[20px] [&>:is(h3,h4,h5,h6)]:text-[16px]",+ "before:pointer-events-none before:float-left before:h-0 before:text-app-placeholder [&:has(>p:only-child>br:only-child)]:before:content-[attr(data-placeholder)]",+ ),+ };+}+export interface PocketNoteEditorHandle {selectionStart: () => number;focusAt: (offset: number) => void;@@ -99,6 +118,10 @@ export function PocketNoteEditor({const [initialDoc] = useState(() => parseNote(value));const changed = useEffectEvent(onChange);const full = useEffectEvent(onFull);+ const t = useT();+ const label = t(m.todayNote);+ const placeholder = t(m.placeholder);+ const attributes = useEffectEvent(() => pageAttributes(label, placeholder));useLayoutEffect(() => {const editor = new EditorView(host.current, {@@ -142,18 +165,7 @@ export function PocketNoteEditor({}),],}),- attributes: {- role: "textbox",- "aria-label": "Today’s note",- "aria-multiline": "true",- "data-placeholder": "Jot anything down. Tomorrow starts a fresh page.",- class: cn(- "min-h-full whitespace-pre-wrap [overflow-wrap:anywhere] outline-none [&>*]:m-0",- "[&>:is(h1,h2,h3,h4,h5,h6)]:font-[580] [&>:is(h1,h2,h3,h4,h5,h6)]:leading-[1.4]",- "[&>h1]:text-[24px] [&>h2]:text-[20px] [&>:is(h3,h4,h5,h6)]:text-[16px]",- "before:pointer-events-none before:float-left before:h-0 before:text-app-placeholder [&:has(>p:only-child>br:only-child)]:before:content-[attr(data-placeholder)]",- ),- },+ attributes: attributes(),clipboardTextParser: (text) => new Slice(parseNote(text).content, 0, 0),clipboardTextSerializer: (slice) => noteText(slice.content),handleDOMEvents: {@@ -179,6 +191,11 @@ export function PocketNoteEditor({};}, [initialDoc, maxLength]);+ // A language switch renames the open page without rebuilding the editor.+ useLayoutEffect(() => {+ view.current?.setProps({ attributes: pageAttributes(label, placeholder) });+ }, [label, placeholder]);+useLayoutEffect(() => {const editor = view.current;if (editor && noteText(editor.state.doc) !== value) {diff --git a/apps/web/src/features/rooms/pocket-notes/pocket-note-language.test.tsx b/apps/web/src/features/rooms/pocket-notes/pocket-note-language.test.tsxnew file mode 100644index 00000000..baacdba0--- /dev/null+++ b/apps/web/src/features/rooms/pocket-notes/pocket-note-language.test.tsx@@ -0,0 +1,103 @@+// @vitest-environment jsdom+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { act, fireEvent, render, screen } from "@testing-library/react";+import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";++import { TeamHubRuntimeProvider } from "@/features/teamhub/teamhub-runtime";+import type { TeamHubPocketNotePage } from "@/features/teamhub/teamhub-types";+import { resetLanguageForTest, setLanguage } from "@/i18n/language";+import zhCN from "@/i18n/locales/zh-CN.json";+import { createTestTeamHubRuntime } from "@/test/teamhub-test-runtime";++import { PocketNoteLauncher } from "./pocket-note-launcher";++const words = zhCN.pocketNotes;+const page: TeamHubPocketNotePage = {+ items: [+ {+ date: "2026-09-30",+ text: "Yesterday's idea",+ updated_at: "2026-09-30T10:00:00Z",+ },+ ],+ page: { has_more: false },+ today: "2026-10-01",+};++function chineseDay(month: number, day: number) {+ return new Intl.DateTimeFormat("zh-CN", {+ day: "numeric",+ month: "short",+ timeZone: "UTC",+ }).format(new Date(Date.UTC(2026, month - 1, day)));+}++function renderLauncher() {+ const runtime = createTestTeamHubRuntime();+ runtime.server.on(+ "GET",+ "/v0/tenants/{tenantId}/me/pocket-notes",+ () => page,+ );+ render(+ <QueryClientProvider client={new QueryClient()}>+ <TeamHubRuntimeProvider runtime={runtime}>+ <PocketNoteLauncher tenantId="tenant-1" />+ </TeamHubRuntimeProvider>+ </QueryClientProvider>,+ );+}++describe("Pocket Notes in the language on screen", () => {+ beforeAll(async () => {+ await import("./pocket-note-panel");+ }, 30_000);+ beforeEach(() => {+ // JSDOM has no text-range layout.+ Object.defineProperties(Range.prototype, {+ getClientRects: { configurable: true, value: () => [] },+ getBoundingClientRect: { configurable: true, value: () => new DOMRect() },+ });+ });+ afterEach(() => {+ resetLanguageForTest();+ });++ it("names today's page and renames it in place when the language changes", async () => {+ await setLanguage("zh-CN");+ renderLauncher();+ fireEvent.click(+ screen.getByRole("button", { name: zhCN.roomList.pocketNotes }),+ );+ const editor = await screen.findByRole("textbox", {+ name: words.todayNote,+ });+ expect(editor).toHaveAttribute("data-placeholder", words.placeholder);+ expect(+ screen.getByText(words.todayTitle.replace("{date}", chineseDay(10, 1))),+ ).toBeInTheDocument();++ await act(() => setLanguage("en"));+ expect(screen.getByRole("textbox", { name: "Today’s note" })).toBe(editor);+ expect(screen.getByText("Today · Oct 1")).toBeInTheDocument();+ });++ it("counts the pages and dates the earlier ones", async () => {+ await setLanguage("zh-CN");+ renderLauncher();+ fireEvent.click(+ screen.getByRole("button", { name: zhCN.roomList.pocketNotes }),+ );+ fireEvent.click(+ await screen.findByRole("button", { name: words.allNotes }),+ );+ expect(+ screen.getByText(words.pageCount.other.replace("{count}", "1")),+ ).toBeInTheDocument();+ expect(+ screen.getByRole("button", {+ name: words.deletePage.replace("{page}", chineseDay(9, 30)),+ }),+ ).toBeInTheDocument();+ });+});diff --git a/apps/web/src/features/rooms/pocket-notes/pocket-note-panel.tsx b/apps/web/src/features/rooms/pocket-notes/pocket-note-panel.tsxindex dc647e76..283ec6d8 100644--- a/apps/web/src/features/rooms/pocket-notes/pocket-note-panel.tsx+++ b/apps/web/src/features/rooms/pocket-notes/pocket-note-panel.tsx@@ -32,6 +32,9 @@ import { useTeamHubRuntime } from "@/features/teamhub/teamhub-runtime";import type { TeamHubPocketNote } from "@/features/teamhub/teamhub-types";import { Button } from "@/components/ui/button";+import { commonMessages } from "@/i18n/common.messages";+import { formatLocale } from "@/i18n/language";+import { useT } from "@/i18n/use-translation";import {pocketNotesQueryOptions,@@ -39,6 +42,7 @@ import {storeTodayPocketNote,} from "./pocket-note-queries";import { LazyVoiceKeyDialog } from "@/features/rooms/voice-control/lazy-voice-key-dialog";+import { pocketNotesMessages as m } from "./pocket-notes.messages";import { usePocketDictation } from "./use-pocket-dictation";import {PocketNoteEditor,@@ -79,6 +83,7 @@ export default function PocketNotePanel({onClose: () => void;tenantId: string;}) {+ const t = useT();const { client } = useTeamHubRuntime();const notes = useInfiniteQuery(pocketNotesQueryOptions(client, tenantId));const [view, setView] = useState<PocketNoteView>({ kind: "today" });@@ -139,7 +144,7 @@ export default function PocketNotePanel({return createPortal(<div- aria-label="Pocket notes"+ aria-label={t(m.panel)}className="app-floating-enter fixed z-[100] flex h-[440px] flex-col overflow-hidden rounded-2xl bg-popover shadow-xl"ref={panelRef}role="dialog"@@ -147,7 +152,7 @@ export default function PocketNotePanel({>{!firstPage || !today ? (<p className="m-auto text-sm text-app-muted">- {notes.isError ? "Couldn’t load notes" : "Loading…"}+ {notes.isError ? t(m.couldNotLoad) : t(commonMessages.loading)}</p>) : view.kind === "all" ? (<AllPocketNotes@@ -204,6 +209,7 @@ function TodayPocketNote({tenantId: string;today: string;}) {+ const t = useT();const { client } = useTeamHubRuntime();const queryClient = useQueryClient();const [text, setText] = useState(initialText);@@ -349,18 +355,20 @@ function TodayPocketNote({const status = dictation.error? dictation.error: truncated- ? "Page is full · 20,000 characters"+ ? t(m.pageFull, {+ limit: maximumNoteLength.toLocaleString(formatLocale()),+ }): dictation.connecting- ? "Connecting…"+ ? t(m.connecting): dictation.stopping- ? "Saving…"+ ? t(m.saving): dictating- ? "Listening…"+ ? t(m.listening): save.isError- ? "Couldn’t save · keep typing to retry"+ ? t(m.couldNotSave): save.isPending || text !== savedText.current- ? "Saving…"- : "Saved";+ ? t(m.saving)+ : t(m.saved);// While speaking, the words still being recognized sit at the anchor.const at = Math.min(anchor.current, text.length);const before = text.slice(0, at);@@ -371,20 +379,20 @@ function TodayPocketNote({<><PocketNoteHeaderleading={- <HeaderButton label="All notes" onClick={onShowAll}>+ <HeaderButton label={t(m.allNotes)} onClick={onShowAll}><Icon icon={GridViewIcon} size={16} /></HeaderButton>}onClose={onClose}subtitle={status}- title={`Today · ${formatPocketNoteDate(today)}`}+ title={t(m.todayTitle, { date: formatPocketNoteDate(today) })}/><div className="relative flex min-h-0 flex-1 flex-col">{dictating ? (// While speaking the page is a read-only view of the note with the// words not yet final shown in place, in gray.<div- aria-label="Today’s note"+ aria-label={t(m.todayNote)}aria-live="polite"className="pocket-note-paper workspace-scrollbar min-h-0 flex-1 overflow-y-auto whitespace-pre-wrap break-words px-5 pb-16 text-sm text-app-ink"role="textbox"@@ -443,7 +451,8 @@ function DictationButton({level: number;onClick: () => void;}) {- const label = active ? "Stop dictation" : "Dictate";+ const t = useT();+ const label = active ? t(m.stopDictation) : t(m.dictate);return (<div className="pointer-events-none absolute bottom-3 right-3 flex items-center gap-2">{active ? (@@ -486,16 +495,17 @@ function PastPocketNote({onBack: () => void;onClose: () => void;}) {+ const t = useT();return (<><PocketNoteHeaderleading={- <HeaderButton label="Back to all notes" onClick={onBack}>+ <HeaderButton label={t(m.backToAllNotes)} onClick={onBack}><Icon icon={ArrowLeft01Icon} size={16} /></HeaderButton>}onClose={onClose}- subtitle="Read only"+ subtitle={t(m.readOnly)}title={formatPocketNoteDate(note.date)}/><div className="pocket-note-paper workspace-scrollbar min-h-0 flex-1 overflow-y-auto break-words px-5 pb-5 text-sm text-app-ink">@@ -524,6 +534,7 @@ function AllPocketNotes({tenantId: string;today: string;}) {+ const t = useT();const { client } = useTeamHubRuntime();const queryClient = useQueryClient();const [confirming, setConfirming] = useState<string>();@@ -548,14 +559,18 @@ function AllPocketNotes({<><PocketNoteHeaderonClose={onClose}- subtitle={`${items.length}${hasMore ? "+" : ""} ${items.length === 1 && !hasMore ? "page" : "pages"}`}- title="All notes"+ subtitle={t(hasMore ? m.pageCountOrMore : m.pageCount, {+ count: items.length,+ })}+ title={t(m.allNotes)}/><div className="workspace-scrollbar min-h-0 flex-1 overflow-y-auto px-4 pb-4"><ul className="grid grid-cols-2 gap-2.5">{cards.map((note) => {const label =- note.date === today ? "Today" : formatPocketNoteDate(note.date);+ note.date === today+ ? t(m.today)+ : formatPocketNoteDate(note.date);return (<li className="group relative" key={note.date}><button@@ -567,12 +582,12 @@ function AllPocketNotes({{label}</span><span className="mt-1.5 line-clamp-4 whitespace-pre-wrap break-words text-xs leading-[18px] text-app-muted">- {markdownPlainText(note.text) || "Nothing written yet"}+ {markdownPlainText(note.text) || t(m.nothingWritten)}</span></button>{note.date === today ? null : confirming === note.date ? (<div- aria-label={`Delete ${label}?`}+ aria-label={t(m.deletePageQuestion, { page: label })}className="absolute inset-0 flex flex-col items-center justify-center gap-2 rounded-xl border border-border bg-card/95 p-3"role="alertdialog">@@ -580,8 +595,8 @@ function AllPocketNotes({className={`text-center text-xs ${remove.isError ? "text-app-danger" : "text-app-ink"}`}>{remove.isError- ? "Couldn’t delete. Try again."- : "Delete this note?"}+ ? t(m.couldNotDelete)+ : t(m.deleteThisNote)}</p><div className="flex gap-1.5"><Button@@ -592,27 +607,29 @@ function AllPocketNotes({size="compact"tone="ghost">- Cancel+ {t(commonMessages.cancel)}</Button><Button+ data-voice-risk="never"loading={remove.isPending}onClick={() => remove.mutate(note.date)}size="compact"tone="danger">- Delete+ {t(commonMessages.delete)}</Button></div></div>) : (<button- aria-label={`Delete ${label}`}+ data-voice-risk="never"+ aria-label={t(m.deletePage, { page: label })}className="absolute right-1.5 top-1.5 flex size-6 items-center justify-center rounded-md text-app-muted opacity-0 transition-opacity hover:bg-accent hover:text-app-danger focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-app-focus group-hover:opacity-100 [@media(hover:none)]:opacity-100"onClick={() => {remove.reset();setConfirming(note.date);}}- title="Delete note"+ title={t(m.deleteNote)}type="button"><Icon icon={Delete02Icon} size={14} />@@ -629,7 +646,7 @@ function AllPocketNotes({onClick={onLoadMore}type="button">- {loadingMore ? "Loading…" : "Load earlier notes"}+ {loadingMore ? t(commonMessages.loading) : t(m.loadEarlier)}</button>) : null}</div>@@ -648,6 +665,7 @@ function PocketNoteHeader({subtitle: string;title: string;}) {+ const t = useT();return (<div className="flex shrink-0 items-center gap-1.5 px-3 pb-2 pt-3">{leading}@@ -657,7 +675,7 @@ function PocketNoteHeader({</p><p className="truncate text-xs leading-4 text-app-muted">{subtitle}</p></div>- <HeaderButton label="Close notes" onClick={onClose}>+ <HeaderButton data-voice-close label={t(m.closeNotes)} onClick={onClose}><Icon icon={Cancel01Icon} size={16} /></HeaderButton></div>@@ -668,14 +686,18 @@ function HeaderButton({children,label,onClick,+ "data-voice-close": closes,}: {children: ReactNode;label: string;onClick: () => void;+ /** The button that closes the panel, for Voice Mode. */+ "data-voice-close"?: boolean;}) {return (<buttonaria-label={label}+ data-voice-close={closes || undefined}className="flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-[background-color,color] hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-app-focus"onClick={onClick}title={label}@@ -722,23 +744,12 @@ function usePanelPosition(return position;}-const monthNames = [- "Jan",- "Feb",- "Mar",- "Apr",- "May",- "Jun",- "Jul",- "Aug",- "Sep",- "Oct",- "Nov",- "Dec",-];-/** "2026-09-30" -> "Sep 30"; TeamHub already chose the page day. */function formatPocketNoteDate(date: string) {- const [, month, day] = date.split("-");- return `${monthNames[Number(month) - 1]} ${Number(day)}`;+ const [year, month, day] = date.split("-").map(Number);+ return new Intl.DateTimeFormat(formatLocale(), {+ day: "numeric",+ month: "short",+ timeZone: "UTC",+ }).format(new Date(Date.UTC(year ?? 0, (month ?? 1) - 1, day ?? 1)));}diff --git a/apps/web/src/features/rooms/pocket-notes/pocket-notes.messages.ts b/apps/web/src/features/rooms/pocket-notes/pocket-notes.messages.tsnew file mode 100644index 00000000..277dbeee--- /dev/null+++ b/apps/web/src/features/rooms/pocket-notes/pocket-notes.messages.ts@@ -0,0 +1,33 @@+import { defineMessages } from "@/i18n/messages";++/** The Pocket Notes notepad: today's page, the pages of earlier days, dictation. */+export const pocketNotesMessages = defineMessages("pocketNotes", {+ panel: "Pocket notes",+ couldNotLoad: "Couldn’t load notes",+ todayTitle: "Today · {date}",+ today: "Today",+ todayNote: "Today’s note",+ placeholder: "Jot anything down. Tomorrow starts a fresh page.",+ allNotes: "All notes",+ backToAllNotes: "Back to all notes",+ closeNotes: "Close notes",+ readOnly: "Read only",+ pageCount: { one: "{count} page", other: "{count} pages" },+ pageCountOrMore: "{count}+ pages",+ nothingWritten: "Nothing written yet",+ loadEarlier: "Load earlier notes",+ saved: "Saved",+ saving: "Saving…",+ couldNotSave: "Couldn’t save · keep typing to retry",+ pageFull: "Page is full · {limit} characters",+ connecting: "Connecting…",+ listening: "Listening…",+ dictate: "Dictate",+ stopDictation: "Stop dictation",+ microphoneOtherTab: "The microphone is active in another tab.",+ deleteNote: "Delete note",+ deletePage: "Delete {page}",+ deletePageQuestion: "Delete {page}?",+ deleteThisNote: "Delete this note?",+ couldNotDelete: "Couldn’t delete. Try again.",+});diff --git a/apps/web/src/features/rooms/pocket-notes/use-pocket-dictation.ts b/apps/web/src/features/rooms/pocket-notes/use-pocket-dictation.tsindex 8f6bbe1c..4e9dbead 100644--- a/apps/web/src/features/rooms/pocket-notes/use-pocket-dictation.ts+++ b/apps/web/src/features/rooms/pocket-notes/use-pocket-dictation.ts@@ -4,12 +4,14 @@ import { useOptionalTeamHubRuntime } from "@/features/teamhub/teamhub-runtime";import { useOptionalVoiceControl } from "@/features/rooms/voice-control/voice-control-context";import { tryAcquireVoicePublisherLease } from "@/features/rooms/voice-control/voice-publisher-lease";import { useVoiceMediaPolicy } from "@/features/rooms/voice-control/use-voice-media-policy";+import { translate } from "@/i18n/language";import {VoiceModeController,type VoiceModeState,} from "../chat/voice-mode/voice-mode-controller";import { openVoiceMode } from "../chat/voice-mode/voice-mode-transport";+import { pocketNotesMessages as m } from "./pocket-notes.messages";const idle: VoiceModeState = {status: "idle",@@ -86,8 +88,7 @@ export function usePocketDictation({resumeListening: false,});const release = await tryAcquireVoicePublisherLease(tenantId);- if (!release)- throw new Error("The microphone is active in another tab.");+ if (!release) throw new Error(translate(m.microphoneOtherTab));return async () => release();},});diff --git a/apps/web/src/i18n/locales/zh-CN.glossary.md b/apps/web/src/i18n/locales/zh-CN.glossary.mdindex 0a6fd49d..4b7daaba 100644--- a/apps/web/src/i18n/locales/zh-CN.glossary.md+++ b/apps/web/src/i18n/locales/zh-CN.glossary.md@@ -74,6 +74,7 @@ elsewhere.| Meeting notes | 会议纪要 | || Meeting summary | 会议摘要 | || Voice Mode | 语音模式 | |+| Dictation | 听写 | Speaking text into a note or the composer. || Draft | 草稿 | || Local model | 本地模型 | || Subscription | 订阅 | A model source. |diff --git a/apps/web/src/i18n/locales/zh-CN.json b/apps/web/src/i18n/locales/zh-CN.jsonindex 440d1f74..e354b0b3 100644--- a/apps/web/src/i18n/locales/zh-CN.json+++ b/apps/web/src/i18n/locales/zh-CN.json@@ -2339,5 +2339,35 @@"openSharedLinkFrom": "打开 {date} 的分享链接","revoke": "撤销","revoked": "已撤销"+ },+ "pocketNotes": {+ "panel": "随手记",+ "couldNotLoad": "无法加载笔记",+ "todayTitle": "今天 · {date}",+ "today": "今天",+ "todayNote": "今天的笔记",+ "placeholder": "想到什么就记下来。明天会换一页新的。",+ "allNotes": "全部笔记",+ "backToAllNotes": "返回全部笔记",+ "closeNotes": "关闭笔记",+ "readOnly": "只读",+ "pageCount": { "other": "{count} 页" },+ "pageCountOrMore": "{count}+ 页",+ "nothingWritten": "还没有写内容",+ "loadEarlier": "加载更早的笔记",+ "saved": "已保存",+ "saving": "正在保存…",+ "couldNotSave": "无法保存 · 继续输入会再试一次",+ "pageFull": "这一页已写满 · {limit} 个字符",+ "connecting": "正在连接…",+ "listening": "正在聆听…",+ "dictate": "听写",+ "stopDictation": "停止听写",+ "microphoneOtherTab": "麦克风正在另一个标签页中使用。",+ "deleteNote": "删除笔记",+ "deletePage": "删除“{page}”这一页",+ "deletePageQuestion": "要删除“{page}”这一页吗?",+ "deleteThisNote": "要删除这篇笔记吗?",+ "couldNotDelete": "无法删除,请再试一次。"}}