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): report the chosen language to the desktop app
Kilyndaa0a40e68ee
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 4d8937cc..988002fd 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -75,9 +75,13 @@ build:assets` to check the initial JS budget.cannot fit only when it needs more than the pool's total. A Computer's detailon the Computers page links here and reads no model state itself.- `src/i18n`: the interface languages (English and Simplified Chinese).- `messages.ts` is the React-free core, `language.ts` holds the language on- screen and the stored choice, `use-translation.tsx` is the React side, and- `locales/` holds one catalog per translated language plus its glossary.+ `messages.ts` re-exports the React-free core from+ `@linger/service-kit/messages`, which the desktop shell shares,+ `language.ts` holds the language on screen and the stored choice,+ `desktop-language.ts` reports a stored choice to the desktop app so its+ menus and pages follow, `use-translation.tsx` is the React side, and+ `locales/` holds one catalog per translated language plus its glossary,+ which the desktop catalog follows too.- `src/test`: unit-test support, including the in-process TeamHub test server.- `e2e`: Playwright product workflows; every spec runs on the real TeamHub andDocument Runtime stack (`make check-e2e-room-document`).diff --git a/apps/web/src/i18n/desktop-language.test.ts b/apps/web/src/i18n/desktop-language.test.tsnew file mode 100644index 00000000..ceebf0cb--- /dev/null+++ b/apps/web/src/i18n/desktop-language.test.ts@@ -0,0 +1,55 @@+// @vitest-environment jsdom+import { afterEach, describe, expect, it, vi } from "vitest";++import { reportLanguageToDesktop } from "./desktop-language";+import {+ LANGUAGE_STORAGE_KEY,+ resetLanguageForTest,+ restoreLanguage,+ setLanguage,+} from "./language";++const desktop = (set = vi.fn(async () => {})) => {+ Object.assign(window, { lingerDesktop: { language: { set } } });+ return set;+};++afterEach(() => {+ delete (window as { lingerDesktop?: unknown }).lingerDesktop;+ localStorage.clear();+ resetLanguageForTest();+});++describe("reportLanguageToDesktop", () => {+ it("leaves the app on the system's language until a choice is made", async () => {+ const set = desktop();+ await restoreLanguage();+ const stop = reportLanguageToDesktop();+ expect(set).not.toHaveBeenCalled();++ await setLanguage("zh-CN");+ expect(set).toHaveBeenLastCalledWith("zh-CN");+ await setLanguage("en");+ expect(set).toHaveBeenLastCalledWith("en");+ stop();+ });++ it("reports the remembered choice when the page starts", async () => {+ localStorage.setItem(LANGUAGE_STORAGE_KEY, "zh-CN");+ const set = desktop();+ await restoreLanguage();+ const stop = reportLanguageToDesktop();+ expect(set).toHaveBeenCalledExactlyOnceWith("zh-CN");+ stop();+ });++ it("keeps the page working when the app refuses or is absent", async () => {+ desktop(vi.fn(async () => Promise.reject(new Error("Not allowed"))));+ const stop = reportLanguageToDesktop();+ await expect(setLanguage("zh-CN")).resolves.toBeUndefined();+ stop();++ delete (window as { lingerDesktop?: unknown }).lingerDesktop;+ expect(() => reportLanguageToDesktop()()).not.toThrow();+ });+});diff --git a/apps/web/src/i18n/desktop-language.ts b/apps/web/src/i18n/desktop-language.tsnew file mode 100644index 00000000..8affee15--- /dev/null+++ b/apps/web/src/i18n/desktop-language.ts@@ -0,0 +1,34 @@+import { getLanguage, storedLanguage, subscribeToLanguage } from "./language";++// The desktop app's side of the language choice+// (`window.lingerDesktop.language`); absent in a browser and in desktop+// builds whose own menus and windows are English only.+interface DesktopLanguage {+ set(language: string): Promise<void>;+}++function desktopLanguage(): DesktopLanguage | undefined {+ return typeof window === "undefined"+ ? undefined+ : (window as { lingerDesktop?: { language?: DesktopLanguage } })+ .lingerDesktop?.language;+}++/**+ * Tells the desktop app the language the person chose, now and on every+ * switch, so its menus, tray, notifications and own windows follow it.+ * Without a remembered choice nothing is reported, and the app keeps+ * following the system's language. Call after `restoreLanguage`.+ */+export function reportLanguageToDesktop(): () => void {+ const api = desktopLanguage();+ if (!api) return () => {};+ const report = () => {+ // An app that cannot take it keeps its current language.+ api.set(getLanguage()).catch(() => {});+ };+ if (storedLanguage()) report();+ // Each switch on screen is a choice: Settings › Language here or in+ // another tab.+ return subscribeToLanguage(report);+}diff --git a/apps/web/src/i18n/language.ts b/apps/web/src/i18n/language.tsindex bb9ae3f0..8b08783a 100644--- a/apps/web/src/i18n/language.ts+++ b/apps/web/src/i18n/language.ts@@ -93,7 +93,8 @@ export function formatLocale(language: Language = translation.language) {return language === "en" ? "en-US" : language;}-function storedLanguage(): Language | undefined {+/** The language the person chose on this device; undefined before any choice. */+export function storedLanguage(): Language | undefined {try {const stored = localStorage.getItem(LANGUAGE_STORAGE_KEY);return isLanguage(stored) ? stored : undefined;diff --git a/apps/web/src/i18n/locales/zh-CN.glossary.md b/apps/web/src/i18n/locales/zh-CN.glossary.mdindex 191d47df..32a9511c 100644--- a/apps/web/src/i18n/locales/zh-CN.glossary.md+++ b/apps/web/src/i18n/locales/zh-CN.glossary.md@@ -9,19 +9,18 @@ Product names and the concepts people see in commands, logs and documentationkeep their English form, so the interface matches what a Human types and readselsewhere.-| Term | Note |-| ------------------------------------ | --------------------------------------------------- |-| Linger, TeamHub | Product names. |-| Agent, Room, Runtime, Skill, Routine | Product concepts. |-| Another Me, Wiki | Feature names. |-| CLI, PowerShell, npm, Node.js | Tools. |-| Claude Code, Codex, Pi, Antigravity | App names. |-| API, URL, BYOK, PDF, Markdown | Abbreviations and formats. |-| Base URL, tokens, Dense, MoE | Model terms people meet in provider documentation. |-| Local Computer | Only when it names the background program. |-| Reconnect This Computer | A desktop menu item, quoted until it is translated. |-| Read All, Write All | Permission names in Composio's dashboard. |-| Issue | Linear's word for a work item. |+| Term | Note |+| ------------------------------------ | -------------------------------------------------- |+| Linger, TeamHub | Product names. |+| Agent, Room, Runtime, Skill, Routine | Product concepts. |+| Another Me, Wiki | Feature names. |+| CLI, PowerShell, npm, Node.js | Tools. |+| Claude Code, Codex, Pi, Antigravity | App names. |+| API, URL, BYOK, PDF, Markdown | Abbreviations and formats. |+| Base URL, tokens, Dense, MoE | Model terms people meet in provider documentation. |+| Local Computer | Only when it names the background program. |+| Read All, Write All | Permission names in Composio's dashboard. |+| Issue | Linear's word for a work item. |## Translated@@ -193,6 +192,10 @@ elsewhere.| Snapshot / Share link | 快照 / 分享链接 | || Revoke | 撤销 | Withdraws a share link. || Yours | 你的 | The tag on an Agent you created. |+| Reconnect This Computer | 重新连接这台电脑 | A desktop menu item; quote it as shown. |+| Diagnostics | 诊断信息 | Logs and settings sent to support. |+| Prevent Sleep | 防止休眠 | A desktop setting. |+| Menu bar / System tray | 菜单栏 / 系统托盘 | Where the desktop app lives. |## Stylediff --git a/apps/web/src/i18n/locales/zh-CN.json b/apps/web/src/i18n/locales/zh-CN.jsonindex 7ed6e5f4..b0f9eaf4 100644--- a/apps/web/src/i18n/locales/zh-CN.json+++ b/apps/web/src/i18n/locales/zh-CN.json@@ -221,8 +221,8 @@"connecting": "正在连接…","connectThisComputer": "连接这台电脑","lookingForApps": "正在这台电脑上查找 Codex 和 Claude Code…",- "desktopAuthFailed": "这台电脑的登录已过期。请在 Linger 的菜单栏菜单中选择 Reconnect This Computer。",- "desktopIdentityConflict": "这台电脑已登记在另一个电脑条目下。请在 Linger 的菜单栏菜单中选择 Reconnect This Computer。",+ "desktopAuthFailed": "这台电脑的登录已过期。请在 Linger 的菜单栏菜单中选择“重新连接这台电脑”。",+ "desktopIdentityConflict": "这台电脑已登记在另一个电脑条目下。请在 Linger 的菜单栏菜单中选择“重新连接这台电脑”。","desktopUpgradeRequired": "请先更新 Linger 应用,再连接这台电脑。","desktopDisconnected": "Linger 后台服务没有运行,请退出并重新打开应用。","desktopRuntimeCrashed": "本地 Runtime 已停止,无法检查 Codex 和 Claude Code。Linger 正在重启它。"diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsxindex e4dc7059..8c3b7808 100644--- a/apps/web/src/main.tsx+++ b/apps/web/src/main.tsx@@ -21,6 +21,7 @@ import { createBrowserTeamHubRuntime } from "@/features/teamhub/browser-teamhub-import { teamHubData } from "@/features/teamhub/teamhub-api";import { TeamHubRuntimeProvider } from "@/features/teamhub/teamhub-runtime";import { commonMessages } from "@/i18n/common.messages";+import { reportLanguageToDesktop } from "@/i18n/desktop-language";import { restoreLanguage } from "@/i18n/language";import { useT } from "@/i18n/use-translation";@@ -38,6 +39,7 @@ const root = createRoot(rootElement);// The remembered language is loaded before the first paint, so its reader// never sees the interface flash by in English. English loads nothing.void restoreLanguage().then(() => {+ reportLanguageToDesktop();root.render(<StrictMode><InitialAppLoading />