Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(i18n): parse imported locale sections in autofill

zipg4ae3e331039c
diff --git a/.github/scripts/i18n-autofill.mjs b/.github/scripts/i18n-autofill.mjs
index 9ec2e4cde3..ca6116f4f5 100644
--- a/.github/scripts/i18n-autofill.mjs
+++ b/.github/scripts/i18n-autofill.mjs
@@ -201,9 +201,7 @@ function assertSamePlaceholders(key, source, translated, locale) {
const sourcePlaceholders = placeholders(source);
const translatedPlaceholders = placeholders(translated);
if (sourcePlaceholders.join("\0") !== translatedPlaceholders.join("\0")) {
- throw new Error(
- `${locale}:${key} placeholder mismatch: expected [${sourcePlaceholders.join(", ")}], got [${translatedPlaceholders.join(", ")}]`,
- );
+ throw new Error(`${locale}:${key} placeholder mismatch: expected [${sourcePlaceholders.join(", ")}], got [${translatedPlaceholders.join(", ")}]`);
}
}
@@ -362,7 +360,7 @@ function flattenNode(node, path, result) {
const nextPath = [...path, property.key];
if (property.value.type === "object") {
flattenNode(property.value, nextPath, result);
- } else {
+ } else if (property.value.type === "string") {
result.set(nextPath.join("."), property.value.value);
}
}
@@ -416,6 +414,12 @@ class Parser {
const start = this.index;
const key = this.parseKey();
this.skipSpace();
+ if (this.peek() === "," || this.peek() === "}") {
+ const hasComma = this.peek() === ",";
+ if (hasComma) this.index += 1;
+ properties.push({ key, start, end: this.index, hasComma, value: { type: "external" } });
+ continue;
+ }
this.expect(":");
this.skipSpace();
const value = this.parseValue();
diff --git a/packages/app-tests/i18nAutofillParser.test.ts b/packages/app-tests/i18nAutofillParser.test.ts
new file mode 100644
index 0000000000..12e0e81dcb
--- /dev/null
+++ b/packages/app-tests/i18nAutofillParser.test.ts
@@ -0,0 +1,11 @@
+import assert from "node:assert/strict";
+import { execFileSync } from "node:child_process";
+import { test } from "vitest";
+
+test("i18n autofill parses locale roots with imported shorthand sections", () => {
+ const output = execFileSync(process.execPath, [".github/scripts/i18n-autofill.mjs", "--dry-run", "--base-ref", "HEAD"], {
+ encoding: "utf8",
+ });
+
+ assert.match(output, /No new zh-CN i18n keys compared with HEAD/);
+});