Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

feat: localize deployed update summaries

tianma-if788849ec39c9
diff --git a/apps/web/src/components/settings/SystemInfoPanel.tsx b/apps/web/src/components/settings/SystemInfoPanel.tsx
index 5dcddefd..7f3e840d 100644
--- a/apps/web/src/components/settings/SystemInfoPanel.tsx
+++ b/apps/web/src/components/settings/SystemInfoPanel.tsx
@@ -1,10 +1,10 @@
import { useMemo, useState } from "react";
-import { Copy, ExternalLink, Sparkles } from "lucide-react";
+import { CircleCheck, Copy, ExternalLink } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import { detectWebClientKind } from "@/lib/client-environment";
import { cn } from "@/lib/utils";
-import { getReleaseTagForVersion } from "@/lib/version-check";
+import { getReleaseTagForVersion, resolveLocalizedReleaseChanges } from "@/lib/version-check";
import { copyTextToClipboard } from "./settings-utils";
export type SystemInfoItem = { label: string; value: string };
@@ -72,9 +72,10 @@ export const SystemInfoPanel = ({ active = true }: { active?: boolean }) => {
const infoItems = useMemo(() => getWebSystemInfoItems(t, i18n.language), [i18n.language, t]);
const isDesktopClient = window.edgeeverDesktop?.isAvailable === true;
const releaseTag = getReleaseTagForVersion(__EDGEEVER_APP_VERSION__);
- const releaseHighlights = i18n.language.toLowerCase().startsWith("zh")
- ? __EDGEEVER_RELEASE_SUMMARY__.changes["zh-CN"]
- : __EDGEEVER_RELEASE_SUMMARY__.changes["en-US"];
+ const releaseHighlights = resolveLocalizedReleaseChanges(
+ __EDGEEVER_RELEASE_SUMMARY__.changes,
+ i18n.resolvedLanguage ?? i18n.language
+ );
const releaseUrl = releaseTag
? `https://github.com/tianma-if/edgeever/releases/tag/${encodeURIComponent(releaseTag)}`
: "https://github.com/tianma-if/edgeever/releases/latest";
@@ -95,7 +96,7 @@ export const SystemInfoPanel = ({ active = true }: { active?: boolean }) => {
</div>
{active && !isDesktopClient ? (
<div className="flex items-start gap-2 rounded-md border border-emerald-200 border-l-2 border-l-emerald-500 bg-emerald-50/40 px-3 py-2 text-slate-800" role="status">
- <Sparkles className="mt-0.5 h-4 w-4 shrink-0 text-emerald-600" />
+ <CircleCheck className="mt-0.5 h-4 w-4 shrink-0 text-emerald-600" />
<div className="min-w-0 flex-1 text-xs leading-5">
<div className="font-semibold">{t("systemInfo.deployedUpdateTitle", { version: releaseTag?.replace(/^v/, "") ?? __EDGEEVER_APP_VERSION__ })}</div>
{releaseHighlights.length > 0 ? (
diff --git a/apps/web/src/lib/version-check.test.mjs b/apps/web/src/lib/version-check.test.mjs
index 17590a76..ccf13ade 100644
--- a/apps/web/src/lib/version-check.test.mjs
+++ b/apps/web/src/lib/version-check.test.mjs
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
-import { findDesktopReleaseVersion, getReleaseTagForVersion, isVersionOutdated } from "./version-check";
+import { findDesktopReleaseVersion, getReleaseTagForVersion, isVersionOutdated, resolveLocalizedReleaseChanges } from "./version-check";
describe("platform release version checks", () => {
test("derives the installed desktop version from the DMG asset", () => {
@@ -37,4 +37,18 @@ describe("platform release version checks", () => {
expect(getReleaseTagForVersion("local")).toBeNull();
});
+ test("selects exact and related locales before falling back to English", () => {
+ const changes = {
+ "en-US": ["English"],
+ "ja-JP": ["日本語"],
+ "pt-BR": ["Português"],
+ "zh-CN": ["中文"],
+ };
+
+ expect(resolveLocalizedReleaseChanges(changes, "ja-JP")).toEqual(["日本語"]);
+ expect(resolveLocalizedReleaseChanges(changes, "pt_PT")).toEqual(["Português"]);
+ expect(resolveLocalizedReleaseChanges(changes, "zh-Hans")).toEqual(["中文"]);
+ expect(resolveLocalizedReleaseChanges(changes, "de-DE")).toEqual(["English"]);
+ });
+
});
diff --git a/apps/web/src/lib/version-check.ts b/apps/web/src/lib/version-check.ts
index e873578e..f3b66a1c 100644
--- a/apps/web/src/lib/version-check.ts
+++ b/apps/web/src/lib/version-check.ts
@@ -29,6 +29,27 @@ export const getReleaseTagForVersion = (version: string) => {
return match ? `v${match[1]}` : null;
};
+const normalizeLocale = (locale: string) => locale.trim().replaceAll("_", "-").toLowerCase();
+
+export const resolveLocalizedReleaseChanges = (
+ changes: Record<string, readonly string[]>,
+ language: string,
+ fallbackLanguage = "en-US"
+) => {
+ const locales = Object.keys(changes);
+ const normalizedLanguage = normalizeLocale(language);
+ const exactLocale = locales.find((locale) => normalizeLocale(locale) === normalizedLanguage);
+ if (exactLocale) return changes[exactLocale];
+
+ const baseLanguage = normalizedLanguage.split("-")[0];
+ const relatedLocale = locales.find((locale) => normalizeLocale(locale).split("-")[0] === baseLanguage);
+ if (relatedLocale) return changes[relatedLocale];
+
+ const normalizedFallback = normalizeLocale(fallbackLanguage);
+ const fallbackLocale = locales.find((locale) => normalizeLocale(locale) === normalizedFallback);
+ return fallbackLocale ? changes[fallbackLocale] : [];
+};
+
export const isVersionOutdated = (currentVersion: string, latestVersion: string) => {
const current = parseVersion(currentVersion);
const latest = parseVersion(latestVersion);
diff --git a/apps/web/src/vite-env.d.ts b/apps/web/src/vite-env.d.ts
index e632c46c..a2c48cc1 100644
--- a/apps/web/src/vite-env.d.ts
+++ b/apps/web/src/vite-env.d.ts
@@ -7,10 +7,7 @@ declare const __EDGEEVER_APP_VERSION__: string;
declare const __EDGEEVER_RELEASED_AT__: string;
declare const __EDGEEVER_RELEASE_SUMMARY__: {
version: string;
- changes: {
- "en-US": string[];
- "zh-CN": string[];
- };
+ changes: Record<string, string[]>;
};
declare const __EDGEEVER_DEPLOYMENT_TRIGGER__: string;
declare const __EDGEEVER_DEPLOYMENT_METHOD__: string;
diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts
index 051b2ded..a350dfcb 100644
--- a/apps/web/vite.config.ts
+++ b/apps/web/vite.config.ts
@@ -22,18 +22,25 @@ const readReleaseSummary = (packageVersion: string) => {
const summaryPath = fileURLToPath(new URL("../../release-summary.json", import.meta.url));
const summary = JSON.parse(readFileSync(summaryPath, "utf8")) as {
version?: unknown;
- changes?: { "en-US"?: unknown; "zh-CN"?: unknown };
+ changes?: unknown;
};
+ const localizedChanges = summary.changes && typeof summary.changes === "object" && !Array.isArray(summary.changes)
+ ? Object.entries(summary.changes)
+ : [];
if (
summary.version !== packageVersion ||
- !Array.isArray(summary.changes?.["en-US"]) ||
- !summary.changes["en-US"].every((item) => typeof item === "string" && item.trim()) ||
- !Array.isArray(summary.changes?.["zh-CN"]) ||
- !summary.changes["zh-CN"].every((item) => typeof item === "string" && item.trim())
+ localizedChanges.length === 0 ||
+ !localizedChanges.every(([locale, changes]) =>
+ /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(locale) &&
+ Array.isArray(changes) &&
+ changes.length > 0 &&
+ changes.every((item) => typeof item === "string" && item.trim())
+ ) ||
+ !localizedChanges.some(([locale]) => locale.toLowerCase() === "en-us")
) {
- throw new Error(`release-summary.json must contain bilingual changes for package version ${packageVersion}.`);
+ throw new Error(`release-summary.json must contain valid localized changes and an en-US fallback for package version ${packageVersion}.`);
}
- return summary as { version: string; changes: { "en-US": string[]; "zh-CN": string[] } };
+ return summary as { version: string; changes: Record<string, string[]> };
};
const readGitCommit = () => {
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index ee1dcc85..2a37fd67 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -581,7 +581,7 @@ export const enUS = {
browserMode: "Browser",
unknown: "Unknown",
copy: "Copy info",
- deployedUpdateTitle: "What's new in v{{version}}",
+ deployedUpdateTitle: "v{{version}} was automatically updated",
releaseNotesUnavailable: "This build does not include an update summary. You can view the full Release notes.",
viewReleaseNotes: "Full notes",
desktopUpdateDownloading: "Downloading update…",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index c55fe7af..233d81a6 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -581,7 +581,7 @@ export const zhCN = {
browserMode: "浏览器",
unknown: "未知",
copy: "复制信息",
- deployedUpdateTitle: "v{{version}} 更新内容",
+ deployedUpdateTitle: "v{{version}} 已自动更新",
releaseNotesUnavailable: "本次构建未包含更新摘要,可查看完整 Release 说明。",
viewReleaseNotes: "完整说明",
desktopUpdateDownloading: "正在下载更新…",
diff --git a/scripts/release.mjs b/scripts/release.mjs
index a02a427d..b882cfc6 100644
--- a/scripts/release.mjs
+++ b/scripts/release.mjs
@@ -70,6 +70,7 @@ Options:
--label <label> Required Issue label; may be repeated
--change-en <text> Required English release bullet; may be repeated
--change-zh <text> Required Chinese release bullet; may be repeated
+ --change-locale <tag:text> Optional localized bullet; repeat once per change and locale
--change-commit <sha,...> Commits covered by the corresponding bilingual bullet
--ignore-commit <sha:why> Explicitly exclude a non-user-facing commit; may be repeated
--skip-install Do not install the final DMG after publication
@@ -85,6 +86,7 @@ export const parseReleaseArgs = (argv) => {
labels: [],
changesEn: [],
changesZh: [],
+ localizedChanges: [],
changeCommits: [],
ignoredCommits: [],
skipInstall: false,
@@ -99,6 +101,7 @@ export const parseReleaseArgs = (argv) => {
["--label", "labels"],
["--change-en", "changesEn"],
["--change-zh", "changesZh"],
+ ["--change-locale", "localizedChanges"],
["--change-commit", "changeCommits"],
["--ignore-commit", "ignoredCommits"],
]);
@@ -158,6 +161,25 @@ export const parseReleaseArgs = (argv) => {
if (options.changesEn.length !== options.changeCommits.length) {
throw new Error("Each bilingual change requires one corresponding --change-commit value.");
}
+ const localizedChanges = {};
+ for (const value of options.localizedChanges) {
+ const separator = value.indexOf(":");
+ const locale = separator === -1 ? "" : value.slice(0, separator).trim();
+ const change = separator === -1 ? "" : value.slice(separator + 1).trim();
+ if (!/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(locale) || !change) {
+ throw new Error('--change-locale must use "<locale>:<user-facing change>".');
+ }
+ if (["en-us", "zh-cn"].includes(locale.toLowerCase())) {
+ throw new Error("Use --change-en and --change-zh for en-US and zh-CN release changes.");
+ }
+ (localizedChanges[locale] ??= []).push(change);
+ }
+ for (const [locale, changes] of Object.entries(localizedChanges)) {
+ if (changes.length !== options.changesEn.length) {
+ throw new Error(`--change-locale ${locale} must provide one translation for every release change.`);
+ }
+ }
+ options.localizedChanges = localizedChanges;
return options;
};
@@ -360,11 +382,12 @@ export const buildReleaseNotes = ({
"",
].join("\n");
-export const buildReleaseSummary = ({ version, changesEn, changesZh }) => ({
+export const buildReleaseSummary = ({ version, changesEn, changesZh, localizedChanges = {} }) => ({
version,
changes: {
"en-US": [...changesEn],
"zh-CN": [...changesZh],
+ ...Object.fromEntries(Object.entries(localizedChanges).map(([locale, changes]) => [locale, [...changes]])),
},
});
@@ -500,7 +523,7 @@ const assertReleasePreconditions = ({ repository, previousTag }) => {
}
};
-const updateReleaseVersions = ({ nextVersion, desktopRebuild, mobileRebuild, changesEn, changesZh }) => {
+const updateReleaseVersions = ({ nextVersion, desktopRebuild, mobileRebuild, changesEn, changesZh, localizedChanges }) => {
const changedPaths = ["package.json", "release-summary.json"];
const rootPackage = readJson("package.json");
rootPackage.version = nextVersion;
@@ -509,6 +532,7 @@ const updateReleaseVersions = ({ nextVersion, desktopRebuild, mobileRebuild, cha
version: nextVersion,
changesEn,
changesZh,
+ localizedChanges,
}));
if (desktopRebuild) {
@@ -892,6 +916,7 @@ const releaseMain = async (options) => {
console.log(buildReleaseNotes({
changesEn: options.changesEn,
changesZh: options.changesZh,
+ localizedChanges: options.localizedChanges,
issueNumber: 0,
}));
return;
diff --git a/scripts/release.test.mjs b/scripts/release.test.mjs
index 5ea62f4e..ddcffe8f 100644
--- a/scripts/release.test.mjs
+++ b/scripts/release.test.mjs
@@ -39,6 +39,8 @@ describe("release automation", () => {
"Run checks in parallel.",
"--change-zh",
"并行运行检查。",
+ "--change-locale",
+ "ja-JP:チェックを並列実行します。",
"--change-commit",
"abc1234",
]),
@@ -48,6 +50,7 @@ describe("release automation", () => {
labels: ["enhancement"],
changesEn: ["Run checks in parallel."],
changesZh: ["并行运行检查。"],
+ localizedChanges: { "ja-JP": ["チェックを並列実行します。"] },
changeCommits: ["abc1234"],
});
});
@@ -183,11 +186,13 @@ describe("release automation", () => {
version: "1.6.55",
changesEn: ["Improve the release flow."],
changesZh: ["优化发布流程。"],
+ localizedChanges: { "ja-JP": ["リリースフローを改善します。"] },
})).toEqual({
version: "1.6.55",
changes: {
"en-US": ["Improve the release flow."],
"zh-CN": ["优化发布流程。"],
+ "ja-JP": ["リリースフローを改善します。"],
},
});
});