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 URL preview panel
Kilyn5626ab21ea24
diff --git a/apps/web/src/features/rooms/task-sidebar/url-preview-panel.tsx b/apps/web/src/features/rooms/task-sidebar/url-preview-panel.tsxindex 10303fa2..787bd4bd 100644--- a/apps/web/src/features/rooms/task-sidebar/url-preview-panel.tsx+++ b/apps/web/src/features/rooms/task-sidebar/url-preview-panel.tsx@@ -8,8 +8,11 @@ import { useEffect, useId, useRef, useState } from "react";import { isDesktopShell } from "@/app/desktop-shell";import { Icon } from "@/components/ui/icon";+import { commonMessages } from "@/i18n/common.messages";+import { useT } from "@/i18n/use-translation";import { shouldOpenUrlExternally } from "../url-preview-policy";+import { urlPreviewMessages as m } from "./url-preview.messages";const previewSandbox = "allow-forms allow-scripts";@@ -66,7 +69,7 @@ function normalizePreviewUrl(value: string) {url.username ||url.password) {- throw new Error("Enter a valid HTTP(S) URL without credentials.");+ throw new Error("Not an HTTP(S) URL without credentials.");}return url.href;}@@ -94,13 +97,14 @@ function UrlPreviewSession({hidden?: boolean;url?: string;}) {+ const t = useT();const initialUrl = safePreviewUrl(url);const [history, setHistory] = useState<string[]>(initialUrl ? [initialUrl] : [],);const [index, setIndex] = useState(initialUrl ? 0 : -1);const [address, setAddress] = useState(initialUrl ?? "");- const [error, setError] = useState<string | null>(null);+ const [invalidAddress, setInvalidAddress] = useState(false);const [reloadKey, setReloadKey] = useState(0);const frameRef = useRef<HTMLIFrameElement>(null);const frameName = PREVIEW_FRAME_PREFIX + useId();@@ -141,9 +145,9 @@ function UrlPreviewSession({setHistory(next);setIndex(next.length - 1);setAddress(url);- setError(null);+ setInvalidAddress(false);} catch {- setError("Enter a valid HTTP(S) URL without credentials.");+ setInvalidAddress(true);}}@@ -152,7 +156,7 @@ function UrlPreviewSession({if (!url) return;setIndex(nextIndex);setAddress(url);- setError(null);+ setInvalidAddress(false);}return (@@ -163,7 +167,7 @@ function UrlPreviewSession({><div className="flex h-11 shrink-0 items-center gap-0.5 border-b border-border bg-card px-2"><button- aria-label="Back"+ aria-label={t(commonMessages.back)}className="flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50"disabled={index <= 0}onClick={() => move(index - 1)}@@ -172,7 +176,7 @@ function UrlPreviewSession({<Icon icon={ArrowLeft01Icon} size={16} /></button><button- aria-label="Forward"+ aria-label={t(m.forward)}className="flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50"disabled={index < 0 || index >= history.length - 1}onClick={() => move(index + 1)}@@ -181,7 +185,7 @@ function UrlPreviewSession({<Icon icon={ArrowRight01Icon} size={16} /></button><button- aria-label="Reload"+ aria-label={t(m.reload)}className="flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"disabled={!currentUrl || externalOnly}onClick={() => setReloadKey((value) => value + 1)}@@ -197,15 +201,15 @@ function UrlPreviewSession({}}><label className="sr-only" htmlFor="panel-url-address">- URL address+ {t(m.urlAddress)}</label><div><input- aria-invalid={Boolean(error)}+ aria-invalid={invalidAddress}className="h-8 w-full rounded-lg border border-transparent bg-transparent px-2 text-center text-xs text-muted-foreground outline-none transition-colors hover:bg-muted/50 focus:border-input focus:bg-card focus:text-foreground"id="panel-url-address"onChange={(event) => setAddress(event.target.value)}- placeholder="Enter URL"+ placeholder={t(m.enterUrl)}spellCheck={false}value={address}/>@@ -213,41 +217,41 @@ function UrlPreviewSession({</form>{currentUrl ? (<a- aria-label="Open in new tab"+ aria-label={t(m.openInNewTab)}className="flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"href={currentUrl}rel="noopener noreferrer"target="_blank"- title="Open in new tab"+ title={t(m.openInNewTab)}><Icon icon={ArrowUpRight01Icon} size={16} /></a>) : null}</div>- {error ? (+ {invalidAddress ? (<pclassName="border-b border-(--app-status-danger-border) bg-(--app-status-danger-surface) px-3 py-2 text-xs text-destructive"role="alert">- {error}+ {t(m.invalidUrl)}</p>) : null}<div className="min-h-0 flex-1 bg-card">{!currentUrl ? (<p className="p-4 text-sm text-muted-foreground">- Enter a URL to preview.+ {t(m.enterUrlToPreview)}</p>) : externalOnly ? (<p className="p-4 text-sm text-muted-foreground">- Open this address in a browser tab to view it.+ {t(m.openInBrowserTab)}</p>) : refused ? (<div className="flex flex-col items-start gap-2 p-4 text-sm"><p className="font-medium text-foreground">- Open this site in a new tab+ {t(m.openSiteInNewTab)}</p><p className="text-muted-foreground">- {new URL(refused.url).host} does not allow being shown in the app.+ {t(m.siteRefusesFrame, { host: new URL(refused.url).host })}</p><aclassName="inline-flex items-center gap-1 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-accent"@@ -255,7 +259,7 @@ function UrlPreviewSession({rel="noopener noreferrer"target="_blank">- Open in new tab+ {t(m.openInNewTab)}<Icon icon={ArrowUpRight01Icon} size={14} /></a></div>@@ -271,7 +275,7 @@ function UrlPreviewSession({: `${previewSandbox} allow-same-origin`}src={previewFrameSrc(currentUrl)}- title={`Preview ${currentUrl}`}+ title={t(m.previewTitle, { url: currentUrl })}/>)}</div>diff --git a/apps/web/src/features/rooms/task-sidebar/url-preview.messages.ts b/apps/web/src/features/rooms/task-sidebar/url-preview.messages.tsnew file mode 100644index 00000000..fa9f1bb6--- /dev/null+++ b/apps/web/src/features/rooms/task-sidebar/url-preview.messages.ts@@ -0,0 +1,17 @@+import { defineMessages } from "@/i18n/messages";++/** The panel that shows a web page beside a Room. */+export const urlPreviewMessages = defineMessages("urlPreview", {+ forward: "Forward",+ reload: "Reload",+ urlAddress: "URL address",+ enterUrl: "Enter URL",+ openInNewTab: "Open in new tab",+ invalidUrl: "Enter a valid HTTP(S) URL without credentials.",+ enterUrlToPreview: "Enter a URL to preview.",+ openInBrowserTab: "Open this address in a browser tab to view it.",+ openSiteInNewTab: "Open this site in a new tab",+ siteRefusesFrame: "{host} does not allow being shown in the app.",+ // The name of the frame that shows the page.+ previewTitle: "Preview {url}",+});diff --git a/apps/web/src/i18n/locales/zh-CN.glossary.md b/apps/web/src/i18n/locales/zh-CN.glossary.mdindex 1a29bbc2..0505bfc4 100644--- a/apps/web/src/i18n/locales/zh-CN.glossary.md+++ b/apps/web/src/i18n/locales/zh-CN.glossary.md@@ -154,6 +154,8 @@ elsewhere.| Active (a connection) | 正常 | A status; `已启用` is for a saved key. || Auto reminders | 自动提醒 | || Popup (authorization) | 弹窗 | `拦截` for a popup the browser blocked. |+| Back / Forward / Reload | 返回 / 前进 / 重新加载 | Buttons of the URL preview panel. |+| Tab (in a browser) | 标签页 | |## Stylediff --git a/apps/web/src/i18n/locales/zh-CN.json b/apps/web/src/i18n/locales/zh-CN.jsonindex 0b05ad24..2e91e789 100644--- a/apps/web/src/i18n/locales/zh-CN.json+++ b/apps/web/src/i18n/locales/zh-CN.json@@ -1963,5 +1963,18 @@"loadingAccess": "正在加载访问权限…","retryAccess": "重新加载访问权限","allowAgentAccess": "允许 Agent 访问 {account}"+ },+ "urlPreview": {+ "forward": "前进",+ "reload": "重新加载",+ "urlAddress": "URL 地址",+ "enterUrl": "输入 URL",+ "openInNewTab": "在新标签页中打开",+ "invalidUrl": "请输入有效的 HTTP(S) URL,并且不要包含凭据。",+ "enterUrlToPreview": "输入 URL 即可预览。",+ "openInBrowserTab": "请在浏览器标签页中打开这个地址查看。",+ "openSiteInNewTab": "在新标签页中打开这个网站",+ "siteRefusesFrame": "{host} 不允许在应用内显示。",+ "previewTitle": "预览 {url}"}}