AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix: localize web clip labels on Android and iOS
tianma-if532d1b8abb30
diff --git a/apps/ios/EdgeEver/Features/Share/WebClipper.swift b/apps/ios/EdgeEver/Features/Share/WebClipper.swiftindex 1d08f73b..c6f9c1f0 100644--- a/apps/ios/EdgeEver/Features/Share/WebClipper.swift+++ b/apps/ios/EdgeEver/Features/Share/WebClipper.swift@@ -18,6 +18,28 @@ struct RenderedWebPage: Equatable, Sendable {var finalURL: String}+struct WebClipLabels: Equatable, Sendable {+ var sourceLabel: String+ var capturedAtLabel: String+ var unavailableBody: String+ var fallbackTitle: String+ var imageAlt: String+ var usesFullwidthColon: Bool++ static let chinese = WebClipLabels(+ sourceLabel: "来源",+ capturedAtLabel: "剪藏时间",+ unavailableBody: "正文暂时无法抓取,来源链接已保留,可稍后重试。",+ fallbackTitle: "网页剪藏",+ imageAlt: "图片",+ usesFullwidthColon: true+ )++ func labeledLine(_ label: String, value: String) -> String {+ usesFullwidthColon ? "\(label):\(value)" : "\(label): \(value)"+ }+}+enum WebClipper {static func sharedWebURL(from payloads: [ShareHandoffStore.SharePayload]) -> URL? {for payload in payloads {@@ -38,7 +60,11 @@ enum WebClipper {&& url.path.hasPrefix("/s")}- static func build(_ sourceURL: URL, capturedAt: Date = Date()) async -> WebClipDraft {+ static func build(+ _ sourceURL: URL,+ capturedAt: Date = Date(),+ labels: WebClipLabels = .chinese+ ) async -> WebClipDraft {var request = URLRequest(url: sourceURL)request.setValue("text/html,application/xhtml+xml", forHTTPHeaderField: "Accept")do {@@ -47,37 +73,44 @@ enum WebClipper {(200 ..< 300).contains(http.statusCode),let html = String(data: data, encoding: .utf8)?? String(data: data, encoding: .isoLatin1)- else { return fallback(sourceURL, capturedAt: capturedAt) }+ else { return fallback(sourceURL, capturedAt: capturedAt, labels: labels) }let finalURL = response.url ?? sourceURL- let title = extractTitle(html) ?? hostnameTitle(sourceURL)+ let title = extractTitle(html) ?? hostnameTitle(sourceURL, fallbackTitle: labels.fallbackTitle)let bodyHTML = firstInnerHTML(html, tags: ["article", "main"])return buildRendered(sourceURL,page: RenderedWebPage(title: title, contentHTML: bodyHTML, finalURL: finalURL.absoluteString),- capturedAt: capturedAt+ capturedAt: capturedAt,+ labels: labels)} catch {- return fallback(sourceURL, capturedAt: capturedAt)+ return fallback(sourceURL, capturedAt: capturedAt, labels: labels)}}static func buildRendered(_ sourceURL: URL,page: RenderedWebPage,- capturedAt: Date = Date()+ capturedAt: Date = Date(),+ labels: WebClipLabels = .chinese) -> WebClipDraft {- let title = normalizedText(page.title).nilIfEmpty ?? hostnameTitle(sourceURL)- let markdown = htmlToMarkdown(page.contentHTML, baseURL: URL(string: page.finalURL) ?? sourceURL)+ let title = normalizedText(page.title).nilIfEmpty ?? hostnameTitle(sourceURL, fallbackTitle: labels.fallbackTitle)+ let markdown = htmlToMarkdown(+ page.contentHTML,+ baseURL: URL(string: page.finalURL) ?? sourceURL,+ imageAlt: labels.imageAlt+ )guard !markdown.isEmpty else {- var draft = fallback(sourceURL, capturedAt: capturedAt)+ var draft = fallback(sourceURL, capturedAt: capturedAt, labels: labels)draft.title = titlereturn draft}+ let sourceLink = "[\(escapeMarkdown(sourceURL.absoluteString))](\(sourceURL.absoluteString))"return WebClipDraft(title: title,contentMarkdown: [- "来源:[\(escapeMarkdown(sourceURL.absoluteString))](\(sourceURL.absoluteString))",- "剪藏时间:\(ISO8601DateFormatter.edgeEver.string(from: capturedAt))",+ labels.labeledLine(labels.sourceLabel, value: sourceLink),+ labels.labeledLine(labels.capturedAtLabel, value: ISO8601DateFormatter.edgeEver.string(from: capturedAt)),"---",markdown,].joined(separator: "\n\n"),@@ -85,19 +118,24 @@ enum WebClipper {)}- static func fallback(_ sourceURL: URL, capturedAt: Date = Date()) -> WebClipDraft {- WebClipDraft(- title: hostnameTitle(sourceURL),+ static func fallback(+ _ sourceURL: URL,+ capturedAt: Date = Date(),+ labels: WebClipLabels = .chinese+ ) -> WebClipDraft {+ let sourceLink = "[\(escapeMarkdown(sourceURL.absoluteString))](\(sourceURL.absoluteString))"+ return WebClipDraft(+ title: hostnameTitle(sourceURL, fallbackTitle: labels.fallbackTitle),contentMarkdown: [- "来源:[\(escapeMarkdown(sourceURL.absoluteString))](\(sourceURL.absoluteString))",- "剪藏时间:\(ISO8601DateFormatter.edgeEver.string(from: capturedAt))",- "正文暂时无法抓取,来源链接已保留,可稍后重试。",+ labels.labeledLine(labels.sourceLabel, value: sourceLink),+ labels.labeledLine(labels.capturedAtLabel, value: ISO8601DateFormatter.edgeEver.string(from: capturedAt)),+ labels.unavailableBody,].joined(separator: "\n\n"),tagsText: isWeChatArticle(sourceURL) ? "web-clip, wechat" : "web-clip")}- static func htmlToMarkdown(_ html: String, baseURL: URL) -> String {+ static func htmlToMarkdown(_ html: String, baseURL: URL, imageAlt: String = "图片") -> String {guard !html.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { return "" }var value = replace(html, pattern: #"<!--[\s\S]*?-->"#) { _ in "" }value = replace(@@ -109,7 +147,7 @@ enum WebClipper {?? attribute(match, "data-original").nilIfEmpty?? attribute(match, "src").nilIfEmptyguard let source, !source.hasPrefix("data:"), let resolved = resolve(source, against: baseURL) else { return "" }- let alt = normalizedText(attribute(match, "alt")).nilIfEmpty ?? "图片"+ let alt = normalizedText(attribute(match, "alt")).nilIfEmpty ?? imageAltreturn "\n\n)\n\n"}value = replace(value, pattern: #"<a\b[^>]*>([\s\S]*?)</a\s*>"#) { match in@@ -164,7 +202,7 @@ enum WebClipper {return ""}- private static func hostnameTitle(_ url: URL) -> String { url.host ?? "网页剪藏" }+ private static func hostnameTitle(_ url: URL, fallbackTitle: String) -> String { url.host ?? fallbackTitle }private static func normalizedText(_ value: String) -> String {decodeEntities(value).replacingOccurrences(of: #"\s+"#, with: " ", options: .regularExpression).trimmingCharacters(in: .whitespacesAndNewlines)diff --git a/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift b/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swiftindex 8ae653a3..75f18924 100644--- a/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift+++ b/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift@@ -223,10 +223,10 @@ struct WorkspaceView: View {ProgressView().controlSize(.large).tint(AppTheme.accent)- Text(env.preferences.t("正在剪藏文章", en: "Clipping article"))+ Text(env.preferences.t("正在剪藏文章", en: "Clipping article", ja: "記事を取り込んでいます")).font(.system(size: 17, weight: .bold)).foregroundStyle(AppTheme.title)- Text(env.preferences.t("正在提取标题、正文和图片链接…", en: "Extracting the title, body, and image links…"))+ Text(env.preferences.t("正在提取标题、正文和图片链接…", en: "Extracting the title, body, and image links…", ja: "タイトル、本文、画像リンクを抽出しています…")).font(.system(size: 13)).foregroundStyle(AppTheme.secondary).multilineTextAlignment(.center)@@ -775,26 +775,67 @@ struct WorkspaceView: View {incomingClipURL = sourceURL} else {Task {- let draft = await WebClipper.build(sourceURL)+ let draft = await WebClipper.build(sourceURL, labels: webClipLabels)finishClip(draft)}}}private func finishRenderedClip(_ page: RenderedWebPage, sourceURL: URL) {- finishClip(WebClipper.buildRendered(sourceURL, page: page))+ finishClip(WebClipper.buildRendered(sourceURL, page: page, labels: webClipLabels))+ }++ private var webClipLabels: WebClipLabels {+ WebClipLabels(+ sourceLabel: env.preferences.t("来源", en: "Source", ja: "出典"),+ capturedAtLabel: env.preferences.t("剪藏时间", en: "Captured at", ja: "取り込み日時"),+ unavailableBody: env.preferences.t(+ "正文暂时无法抓取,来源链接已保留,可稍后重试。",+ en: "Could not extract the page text. The source link is kept so you can retry later.",+ ja: "本文を取り込めませんでした。出典リンクは残してあるので、あとからやり直せます。"+ ),+ fallbackTitle: env.preferences.t("网页剪藏", en: "Web clip", ja: "ウェブクリップ"),+ imageAlt: env.preferences.t("图片", en: "Image", ja: "画像"),+ usesFullwidthColon: env.preferences.uiLanguage == .chinese+ )+ }++ private func localizedCaptureFailure(_ message: String) -> String {+ switch message {+ case "微信文章加载超时。":+ return env.preferences.t(+ "微信文章加载超时。",+ en: "The WeChat article took too long to load.",+ ja: "WeChat 記事の読み込みがタイムアウトしました。"+ )+ case "页面加载完成,但没有找到可剪藏的正文。":+ return env.preferences.t(+ "页面加载完成,但没有找到可剪藏的正文。",+ en: "The page finished loading, but there was no article text to clip.",+ ja: "ページの読み込みは終わりましたが、取り込める本文がありません。"+ )+ case "没有找到可剪藏的正文。":+ return env.preferences.t(+ "没有找到可剪藏的正文。",+ en: "No article text was found to clip.",+ ja: "取り込める本文が見つかりません。"+ )+ default:+ return message+ }}private func failRenderedClip(_ message: String, sourceURL: URL) {incomingClipURL = nilTask {- let draft = await WebClipper.build(sourceURL)+ let draft = await WebClipper.build(sourceURL, labels: webClipLabels)isImportingShare = falseshareImportAlert = ShareImportAlert(- title: env.preferences.t("正文剪藏失败", en: "Article extraction failed"),- message: message + env.preferences.t(- " 已保留文章链接,你可以稍后重新分享重试。",- en: " The article link was preserved; you can share it again later to retry."+ title: env.preferences.t("正文剪藏失败", en: "Article extraction failed", ja: "本文を取り込めませんでした"),+ message: localizedCaptureFailure(message) + " " + env.preferences.t(+ "已保留文章链接,你可以稍后重新分享重试。",+ en: "The article link was kept. Share it again later to retry.",+ ja: "記事リンクは残してあります。あとから再共有してやり直せます。"),draft: draft)diff --git a/apps/ios/Tests/EdgeEverTests/WebClipperTests.swift b/apps/ios/Tests/EdgeEverTests/WebClipperTests.swiftindex f2182b82..aeecb6d8 100644--- a/apps/ios/Tests/EdgeEverTests/WebClipperTests.swift+++ b/apps/ios/Tests/EdgeEverTests/WebClipperTests.swift@@ -95,6 +95,56 @@ final class WebClipperTests: XCTestCase {)XCTAssertEqual(draft.title, "Known title")XCTAssertTrue(draft.contentMarkdown.contains("正文暂时无法抓取"))+ XCTAssertTrue(draft.contentMarkdown.contains("来源:"))+ XCTAssertTrue(draft.contentMarkdown.contains("剪藏时间:"))XCTAssertTrue(draft.contentMarkdown.contains(source.absoluteString))}++ func testEnglishLabelsAreWrittenIntoTheNote() throws {+ let source = try XCTUnwrap(URL(string: "https://example.com/story"))+ let labels = WebClipLabels(+ sourceLabel: "Source",+ capturedAtLabel: "Captured at",+ unavailableBody: "Could not extract the page text. The source link is kept so you can retry later.",+ fallbackTitle: "Web clip",+ imageAlt: "Image",+ usesFullwidthColon: false+ )+ let draft = WebClipper.buildRendered(+ source,+ page: RenderedWebPage(+ title: "Story",+ contentHTML: "<p>Body</p><img src=\"/a.png\">",+ finalURL: source.absoluteString+ ),+ capturedAt: Date(timeIntervalSince1970: 0),+ labels: labels+ )++ XCTAssertTrue(draft.contentMarkdown.contains("Source: [https://example.com/story](https://example.com/story)"))+ XCTAssertTrue(draft.contentMarkdown.contains("Captured at:"))+ XCTAssertTrue(draft.contentMarkdown.contains(""))+ XCTAssertFalse(draft.contentMarkdown.contains("来源"))+ }++ func testJapaneseFallbackKeepsTheSourceLink() throws {+ let source = try XCTUnwrap(URL(string: "https://example.com/missing"))+ let labels = WebClipLabels(+ sourceLabel: "出典",+ capturedAtLabel: "取り込み日時",+ unavailableBody: "本文を取り込めませんでした。出典リンクは残してあるので、あとからやり直せます。",+ fallbackTitle: "ウェブクリップ",+ imageAlt: "画像",+ usesFullwidthColon: false+ )+ let draft = WebClipper.buildRendered(+ source,+ page: RenderedWebPage(title: "", contentHTML: " ", finalURL: source.absoluteString),+ labels: labels+ )++ XCTAssertEqual(draft.title, "example.com")+ XCTAssertTrue(draft.contentMarkdown.contains("出典: [https://example.com/missing](https://example.com/missing)"))+ XCTAssertTrue(draft.contentMarkdown.contains("本文を取り込めませんでした"))+ }}diff --git a/apps/mobile/src/lib/mobile-locale.test.mjs b/apps/mobile/src/lib/mobile-locale.test.mjsindex e7947be8..c412e9d3 100644--- a/apps/mobile/src/lib/mobile-locale.test.mjs+++ b/apps/mobile/src/lib/mobile-locale.test.mjs@@ -33,6 +33,12 @@ describe("mobile locale translation", () => {expect(translateMobileText("切换产品界面的显示语言。", "en-US")).toBe("Choose the language used in the app.");expect(translateMobileText("当前密码不正确。", "en-US")).toBe("The current password is incorrect.");expect(translateMobileText("修改中...", "ja")).toBe("変更中...");+ expect(translateMobileText("正在剪藏文章", "en-US")).toBe("Clipping article");+ expect(translateMobileText("剪藏失败", "ja")).toBe("ページを取り込めませんでした");+ expect(translateMobileText("正文剪藏失败", "en-US")).toBe("Article extraction failed");+ expect(translateMobileText("微信文章请求失败(HTTP 404)。", "en-US")).toBe("The WeChat article request failed (HTTP 404).");+ expect(translateMobileText("分享的图片(2 张)", "ja")).toBe("共有された画像(2 枚)");+ expect(translateMobileText("来源:https://example.com", "en-US")).toBe("来源:https://example.com");});test("localizes only the default untitled title and the missing-notebook fallback", () => {diff --git a/apps/mobile/src/lib/mobile-locale.tsx b/apps/mobile/src/lib/mobile-locale.tsxindex c71d02b5..dac15982 100644--- a/apps/mobile/src/lib/mobile-locale.tsx+++ b/apps/mobile/src/lib/mobile-locale.tsx@@ -181,6 +181,27 @@ const mobileOnlyTranslations = new Map<string, string>([["首次登录密码", "Password for first sign-in"],["GitHub 仓库", "GitHub repository"],["操作失败,请稍后再试", "Something went wrong. Please try again."],+ ["正在剪藏文章", "Clipping article"],+ ["正在提取标题、正文和图片链接…", "Extracting the title, body, and image links…"],+ ["正文剪藏失败", "Article extraction failed"],+ ["已保留文章链接,你可以稍后重新分享重试。", "The article link was kept. Share it again later to retry."],+ ["页面加载完成,但没有找到可剪藏的正文。", "The page finished loading, but there was no article text to clip."],+ ["微信文章加载超时。", "The WeChat article took too long to load."],+ ["没有找到可剪藏的正文。", "No article text was found to clip."],+ ["无法解析微信文章正文。", "Could not read the WeChat article text."],+ ["微信文章加载失败。", "Could not load the WeChat article."],+ ["微信文章请求失败(HTTP {{status}})。", "The WeChat article request failed (HTTP {{status}})."],+ ["无法读取分享图片", "Could not read the shared image"],+ ["请重新分享后再试。", "Share it again and retry."],+ ["无法保存图片", "Unable to save images"],+ ["请先在 EdgeEver 中创建一个笔记本。", "Create a notebook in EdgeEver first."],+ ["分享的图片", "Shared image"],+ ["分享的图片({{count}} 张)", "Shared images ({{count}})"],+ ["无法读取分享内容", "Could not read the shared content"],+ ["分享内容里没有可识别的网页链接或图片。", "The shared content has no recognizable web link or image."],+ ["无法保存剪藏", "Unable to save clip"],+ ["剪藏失败", "Could not clip the page"],+ ["无法读取分享的网页,请稍后重试。", "Could not read the shared page. Try again later."],]);const mobileOnlyJapanese = new Map<string, string>([@@ -345,6 +366,27 @@ const mobileOnlyJapanese = new Map<string, string>([["首次登录密码", "初回ログインのパスワード"],["GitHub 仓库", "GitHub リポジトリ"],["操作失败,请稍后再试", "操作に失敗しました。しばらくしてから再試行してください。"],+ ["正在剪藏文章", "記事を取り込んでいます"],+ ["正在提取标题、正文和图片链接…", "タイトル、本文、画像リンクを抽出しています…"],+ ["正文剪藏失败", "本文を取り込めませんでした"],+ ["已保留文章链接,你可以稍后重新分享重试。", "記事リンクは残してあります。あとから再共有してやり直せます。"],+ ["页面加载完成,但没有找到可剪藏的正文。", "ページの読み込みは終わりましたが、取り込める本文がありません。"],+ ["微信文章加载超时。", "WeChat 記事の読み込みがタイムアウトしました。"],+ ["没有找到可剪藏的正文。", "取り込める本文が見つかりません。"],+ ["无法解析微信文章正文。", "WeChat 記事の本文を読み取れませんでした。"],+ ["微信文章加载失败。", "WeChat 記事を読み込めませんでした。"],+ ["微信文章请求失败(HTTP {{status}})。", "WeChat 記事のリクエストに失敗しました(HTTP {{status}})。"],+ ["无法读取分享图片", "共有された画像を読み取れませんでした"],+ ["请重新分享后再试。", "もう一度共有してから再試行してください。"],+ ["无法保存图片", "画像を保存できませんでした"],+ ["请先在 EdgeEver 中创建一个笔记本。", "先に EdgeEver でノートブックを作成してください。"],+ ["分享的图片", "共有された画像"],+ ["分享的图片({{count}} 张)", "共有された画像({{count}} 枚)"],+ ["无法读取分享内容", "共有された内容を読み取れませんでした"],+ ["分享内容里没有可识别的网页链接或图片。", "共有された内容に、認識できるウェブリンクも画像もありません。"],+ ["无法保存剪藏", "クリップを保存できませんでした"],+ ["剪藏失败", "ページを取り込めませんでした"],+ ["无法读取分享的网页,请稍后重试。", "共有されたページを読み取れませんでした。しばらくしてから再試行してください。"],]);const flattenStrings = (value: unknown, prefix = "", output = new Map<string, string>()) => {diff --git a/apps/mobile/src/lib/mobile-web-clip.test.ts b/apps/mobile/src/lib/mobile-web-clip.test.tsindex 05ef7258..942da0e1 100644--- a/apps/mobile/src/lib/mobile-web-clip.test.ts+++ b/apps/mobile/src/lib/mobile-web-clip.test.ts@@ -106,6 +106,40 @@ describe("mobile web clip", () => {},});expect(draft.contentMarkdown).toContain("https://mp.weixin.qq.com/s/offline");+ expect(draft.contentMarkdown).toContain("来源:");+ expect(draft.contentMarkdown).toContain("剪藏时间:");expect(draft.contentMarkdown).toContain("正文暂时无法抓取");});++ test("writes English source labels into a new clip", () => {+ const draft = buildMobileWebClipDraftFromRenderedPage(+ "https://example.com/story",+ {+ title: "Story",+ finalUrl: "https://example.com/story",+ contentHtml: "<p>Body</p><img src=\"https://example.com/a.png\">",+ },+ { capturedAt: new Date("2026-07-31T00:00:00.000Z"), locale: "en-US" },+ );++ expect(draft.contentMarkdown).toContain("Source: [https://example.com/story](https://example.com/story)");+ expect(draft.contentMarkdown).toContain("Captured at: 2026-07-31T00:00:00.000Z");+ expect(draft.contentMarkdown).toContain("");+ expect(draft.contentMarkdown).not.toContain("来源");+ });++ test("writes Japanese labels when the page cannot be fetched", async () => {+ const draft = await buildMobileWebClipDraft("notaurl", {+ capturedAt: new Date("2026-07-31T00:00:00.000Z"),+ fetcher: async () => {+ throw new Error("offline");+ },+ locale: "ja",+ });++ expect(draft.title).toBe("ウェブクリップ");+ expect(draft.contentMarkdown).toContain("出典: [notaurl](notaurl)");+ expect(draft.contentMarkdown).toContain("取り込み日時: 2026-07-31T00:00:00.000Z");+ expect(draft.contentMarkdown).toContain("本文を取り込めませんでした。出典リンクは残してあるので、あとからやり直せます。");+ });});diff --git a/apps/mobile/src/lib/mobile-web-clip.ts b/apps/mobile/src/lib/mobile-web-clip.tsindex 8f933f89..9301fe99 100644--- a/apps/mobile/src/lib/mobile-web-clip.ts+++ b/apps/mobile/src/lib/mobile-web-clip.ts@@ -27,6 +27,42 @@ export type MobileRenderedWebPage = {title?: string;};+export type MobileWebClipLocale = "zh-CN" | "en-US" | "ja";++const webClipCopy: Record<MobileWebClipLocale, {+ capturedAtLabel: string;+ fallbackTitle: string;+ imageAlt: string;+ separator: string;+ sourceLabel: string;+ unavailableBody: string;+}> = {+ "zh-CN": {+ sourceLabel: "来源",+ capturedAtLabel: "剪藏时间",+ unavailableBody: "正文暂时无法抓取,来源链接已保留,可稍后重试。",+ fallbackTitle: "网页剪藏",+ imageAlt: "图片",+ separator: ":",+ },+ "en-US": {+ sourceLabel: "Source",+ capturedAtLabel: "Captured at",+ unavailableBody: "Could not extract the page text. The source link is kept so you can retry later.",+ fallbackTitle: "Web clip",+ imageAlt: "Image",+ separator: ": ",+ },+ ja: {+ sourceLabel: "出典",+ capturedAtLabel: "取り込み日時",+ unavailableBody: "本文を取り込めませんでした。出典リンクは残してあるので、あとからやり直せます。",+ fallbackTitle: "ウェブクリップ",+ imageAlt: "画像",+ separator: ": ",+ },+};+const URL_PATTERN = /https?:\/\/[^\s<>"'))]+/i;const WECHAT_ARTICLE_HOSTS = new Set(["mp.weixin.qq.com"]);const BLOCK_TAGS = new Set([@@ -114,10 +150,12 @@ export const buildMobileWebClipDraft = async (options: {fetcher?: typeof fetch;capturedAt?: Date;+ locale?: MobileWebClipLocale;} = {}): Promise<MobileWebClipDraft> => {const fetcher = options.fetcher ?? fetch;const capturedAt = options.capturedAt ?? new Date();+ const locale = options.locale ?? "zh-CN";let html = "";let finalUrl = sourceUrl;@@ -133,10 +171,10 @@ export const buildMobileWebClipDraft = async (finalUrl = response.url || sourceUrl;html = await response.text();} catch {- return buildFallbackDraft(sourceUrl, capturedAt);+ return buildFallbackDraft(sourceUrl, capturedAt, locale);}- const title = extractPageTitle(html) || hostnameTitle(sourceUrl);+ const title = extractPageTitle(html) || hostnameTitle(sourceUrl, locale);const articleHtml = isWeChatArticleUrl(sourceUrl)? extractElementInnerHtmlById(html, "js_content"): extractFirstElementInnerHtml(html, ["article", "main"]);@@ -147,7 +185,7 @@ export const buildMobileWebClipDraft = async (finalUrl,title,},- { capturedAt },+ { capturedAt, locale },);};@@ -156,14 +194,17 @@ export const buildMobileWebClipDraftFromRenderedPage = (page: MobileRenderedWebPage,options: {capturedAt?: Date;+ locale?: MobileWebClipLocale;} = {},): MobileWebClipDraft => {const capturedAt = options.capturedAt ?? new Date();- const title = normalizeInlineText(page.title ?? "") || hostnameTitle(sourceUrl);- const body = htmlToMarkdown(page.contentHtml, page.finalUrl || sourceUrl);+ const locale = options.locale ?? "zh-CN";+ const copy = webClipCopy[locale];+ const title = normalizeInlineText(page.title ?? "") || hostnameTitle(sourceUrl, locale);+ const body = htmlToMarkdown(page.contentHtml, page.finalUrl || sourceUrl, copy.imageAlt);if (!body) {- return { ...buildFallbackDraft(sourceUrl, capturedAt), title };+ return { ...buildFallbackDraft(sourceUrl, capturedAt, locale), title };}return {@@ -171,8 +212,8 @@ export const buildMobileWebClipDraftFromRenderedPage = (sourceUrl,tagsText: isWeChatArticleUrl(sourceUrl) ? "web-clip, wechat" : "web-clip",contentMarkdown: [- `来源:[${escapeMarkdownText(sourceUrl)}](${sourceUrl})`,- `剪藏时间:${capturedAt.toISOString()}`,+ clipMetadataLine(copy.sourceLabel, `[${escapeMarkdownText(sourceUrl)}](${sourceUrl})`, copy.separator),+ clipMetadataLine(copy.capturedAtLabel, capturedAt.toISOString(), copy.separator),"---",body,].join("\n\n"),@@ -196,7 +237,7 @@ export const extractPageTitle = (html: string) => {return titleMatch ? normalizeInlineText(stripTags(titleMatch[1])) : "";};-export const htmlToMarkdown = (html: string, baseUrl?: string) => {+export const htmlToMarkdown = (html: string, baseUrl?: string, imageAlt = "图片") => {if (!html.trim()) {return "";}@@ -214,7 +255,7 @@ export const htmlToMarkdown = (html: string, baseUrl?: string) => {if (!resolvedSrc) {return "";}- const alt = normalizeInlineText(readAttribute(tag, "alt") || "图片");+ const alt = normalizeInlineText(readAttribute(tag, "alt") || imageAlt);return `\n\n\n\n`;});@@ -257,23 +298,32 @@ export const htmlToMarkdown = (html: string, baseUrl?: string) => {.trim();};-const buildFallbackDraft = (sourceUrl: string, capturedAt: Date): MobileWebClipDraft => ({- title: hostnameTitle(sourceUrl),- sourceUrl,- tagsText: isWeChatArticleUrl(sourceUrl) ? "web-clip, wechat" : "web-clip",- contentMarkdown: [- `来源:[${escapeMarkdownText(sourceUrl)}](${sourceUrl})`,- `剪藏时间:${capturedAt.toISOString()}`,- "",- "正文暂时无法抓取,来源链接已保留,可稍后重试。",- ].join("\n\n"),-});--const hostnameTitle = (value: string) => {+const clipMetadataLine = (label: string, value: string, separator: string) => `${label}${separator}${value}`;++const buildFallbackDraft = (+ sourceUrl: string,+ capturedAt: Date,+ locale: MobileWebClipLocale,+): MobileWebClipDraft => {+ const copy = webClipCopy[locale];+ return {+ title: hostnameTitle(sourceUrl, locale),+ sourceUrl,+ tagsText: isWeChatArticleUrl(sourceUrl) ? "web-clip, wechat" : "web-clip",+ contentMarkdown: [+ clipMetadataLine(copy.sourceLabel, `[${escapeMarkdownText(sourceUrl)}](${sourceUrl})`, copy.separator),+ clipMetadataLine(copy.capturedAtLabel, capturedAt.toISOString(), copy.separator),+ "",+ copy.unavailableBody,+ ].join("\n\n"),+ };+};++const hostnameTitle = (value: string, locale: MobileWebClipLocale = "zh-CN") => {try {return new URL(value).hostname;} catch {- return "网页剪藏";+ return webClipCopy[locale].fallbackTitle;}};diff --git a/apps/mobile/src/screens/WorkspaceScreen.tsx b/apps/mobile/src/screens/WorkspaceScreen.tsxindex 777df86f..a37aab2c 100644--- a/apps/mobile/src/screens/WorkspaceScreen.tsx+++ b/apps/mobile/src/screens/WorkspaceScreen.tsx@@ -140,7 +140,7 @@ export const WorkspaceScreen = ({onIncomingShareHandled?: () => void;}) => {const { resolvedTheme } = useMobileTheme();- const { preference: localePreference, resolvedLocale, setPreference: setLocalePreference } = useMobileLocale();+ const { preference: localePreference, resolvedLocale, setPreference: setLocalePreference, translate } = useMobileLocale();const hasUpdate = useMobileUpdateAvailable();refreshWorkspaceThemeStyles(resolvedTheme);const { client, session, signOut } = useSession();@@ -550,25 +550,25 @@ export const WorkspaceScreen = ({const handleRenderedClipCaptured = useCallback((page: MobileRenderedWebPage) => {if (!incomingClipCaptureUrl) return;openIncomingClipDraft(- buildMobileWebClipDraftFromRenderedPage(incomingClipCaptureUrl, page),+ buildMobileWebClipDraftFromRenderedPage(incomingClipCaptureUrl, page, { locale: resolvedLocale }),);finishIncomingShare();- }, [finishIncomingShare, incomingClipCaptureUrl, openIncomingClipDraft]);+ }, [finishIncomingShare, incomingClipCaptureUrl, openIncomingClipDraft, resolvedLocale]);const handleRenderedClipFailed = useCallback((message: string) => {const sourceUrl = incomingClipCaptureUrl;if (!sourceUrl) return;setIncomingClipCaptureUrl(null);- void buildMobileWebClipDraft(sourceUrl)+ void buildMobileWebClipDraft(sourceUrl, { locale: resolvedLocale }).then((draft) => {openIncomingClipDraft(draft);Alert.alert("正文剪藏失败",- `${message} 已保留文章链接,你可以稍后重新分享重试。`,+ `${translate(message)} ${translate("已保留文章链接,你可以稍后重新分享重试。")}`,);}).finally(finishIncomingShare);- }, [finishIncomingShare, incomingClipCaptureUrl, openIncomingClipDraft]);+ }, [finishIncomingShare, incomingClipCaptureUrl, openIncomingClipDraft, resolvedLocale, translate]);useEffect(() => {if (incomingShareIsResolving) {@@ -606,7 +606,7 @@ export const WorkspaceScreen = ({setCreateSeed({contentMarkdown: "",tagsText: "",- title: sharedImages.length === 1 ? "分享的图片" : `分享的图片(${sharedImages.length} 张)`,+ title: translate(sharedImages.length === 1 ? "分享的图片" : `分享的图片(${sharedImages.length} 张)`),});setActiveView("notes");setMemoView("notebook");@@ -650,7 +650,7 @@ export const WorkspaceScreen = ({active = false;};}- void buildMobileWebClipDraft(sourceUrl)+ void buildMobileWebClipDraft(sourceUrl, { locale: resolvedLocale }).then((draft) => {if (!active) {return;@@ -680,7 +680,9 @@ export const WorkspaceScreen = ({notebooks.length,notebooksQuery.isSuccess,openIncomingClipDraft,+ resolvedLocale,sharedImages,+ translate,]);useEffect(() => {