feat: import Chinese-localized Buzz source snapshot
Docker image / Build (linux/amd64) (push) Has been cancelled
Docker image / Build (linux/arm64) (push) Has been cancelled
Docker image / Merge release multi-arch manifest (push) Has been cancelled
Docker image / Merge debug multi-arch manifest (push) Has been cancelled
Docker image / Build public push gateway (linux/amd64) (push) Has been cancelled
Docker image / Build public push gateway (linux/arm64) (push) Has been cancelled
Docker image / Publish public push gateway image (push) Has been cancelled
Sprig image / Build (linux/amd64) (push) Has been cancelled
Sprig image / Build (linux/arm64) (push) Has been cancelled
Sprig image / Merge multi-arch manifest (push) Has been cancelled
Harbor Buzz Orchestra / Python tests and lint (push) Has been cancelled
CI / Detect Changed Paths (push) Has been cancelled
CI / Rust Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Desktop Core (push) Has been cancelled
CI / Desktop Smoke E2E (1) (push) Has been cancelled
CI / Desktop Smoke E2E (2) (push) Has been cancelled
CI / Desktop Smoke E2E (3) (push) Has been cancelled
CI / Desktop Smoke E2E (4) (push) Has been cancelled
CI / Desktop (push) Has been cancelled
CI / Desktop E2E Relay (push) Has been cancelled
CI / Desktop E2E Integration (1/2) (push) Has been cancelled
CI / Desktop E2E Integration (2/2) (push) Has been cancelled
CI / Desktop E2E Integration (push) Has been cancelled
CI / Backend Integration (relay e2e) (push) Has been cancelled
CI / Relay E2E (push) Has been cancelled
CI / Web (push) Has been cancelled
CI / Mobile (push) Has been cancelled
CI / Security (push) Has been cancelled
CI / Dead Token Reference Guard (push) Has been cancelled
CI / Server Cross-Compile (aarch64-unknown-linux-musl) (push) Has been cancelled
CI / Server Cross-Compile (x86_64-unknown-linux-musl) (push) Has been cancelled
CI / Windows Rust (x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Desktop Build (macOS) (push) Has been cancelled
helm chart / lint + unittest + render matrix (push) Has been cancelled
helm chart / install on kind (gated) (push) Has been cancelled
helm chart / publish chart to GHCR (push) Has been cancelled
Mesh Lifecycle / Relay-Driven Mesh Lifecycle Smoke (push) Has been cancelled
Sprig / Build (aarch64-unknown-linux-musl) (push) Has been cancelled
Sprig / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Sprig / Publish rolling release (push) Has been cancelled
Sprig / Publish tagged release (push) Has been cancelled
Docker image / Build (linux/amd64) (push) Has been cancelled
Docker image / Build (linux/arm64) (push) Has been cancelled
Docker image / Merge release multi-arch manifest (push) Has been cancelled
Docker image / Merge debug multi-arch manifest (push) Has been cancelled
Docker image / Build public push gateway (linux/amd64) (push) Has been cancelled
Docker image / Build public push gateway (linux/arm64) (push) Has been cancelled
Docker image / Publish public push gateway image (push) Has been cancelled
Sprig image / Build (linux/amd64) (push) Has been cancelled
Sprig image / Build (linux/arm64) (push) Has been cancelled
Sprig image / Merge multi-arch manifest (push) Has been cancelled
Harbor Buzz Orchestra / Python tests and lint (push) Has been cancelled
CI / Detect Changed Paths (push) Has been cancelled
CI / Rust Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Desktop Core (push) Has been cancelled
CI / Desktop Smoke E2E (1) (push) Has been cancelled
CI / Desktop Smoke E2E (2) (push) Has been cancelled
CI / Desktop Smoke E2E (3) (push) Has been cancelled
CI / Desktop Smoke E2E (4) (push) Has been cancelled
CI / Desktop (push) Has been cancelled
CI / Desktop E2E Relay (push) Has been cancelled
CI / Desktop E2E Integration (1/2) (push) Has been cancelled
CI / Desktop E2E Integration (2/2) (push) Has been cancelled
CI / Desktop E2E Integration (push) Has been cancelled
CI / Backend Integration (relay e2e) (push) Has been cancelled
CI / Relay E2E (push) Has been cancelled
CI / Web (push) Has been cancelled
CI / Mobile (push) Has been cancelled
CI / Security (push) Has been cancelled
CI / Dead Token Reference Guard (push) Has been cancelled
CI / Server Cross-Compile (aarch64-unknown-linux-musl) (push) Has been cancelled
CI / Server Cross-Compile (x86_64-unknown-linux-musl) (push) Has been cancelled
CI / Windows Rust (x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Desktop Build (macOS) (push) Has been cancelled
helm chart / lint + unittest + render matrix (push) Has been cancelled
helm chart / install on kind (gated) (push) Has been cancelled
helm chart / publish chart to GHCR (push) Has been cancelled
Mesh Lifecycle / Relay-Driven Mesh Lifecycle Smoke (push) Has been cancelled
Sprig / Build (aarch64-unknown-linux-musl) (push) Has been cancelled
Sprig / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Sprig / Publish rolling release (push) Has been cancelled
Sprig / Publish tagged release (push) Has been cancelled
Signed-off-by: cls_宁波本机 <908705107@qq.com>
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
import { readFileSync, readdirSync, statSync } from "node:fs";
|
||||
import { dirname, join, relative } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const mobileDir = dirname(dirname(fileURLToPath(import.meta.url)));
|
||||
const sourceDir = join(mobileDir, "lib");
|
||||
const arbFiles = ["app_en.arb", "app_zh_CN.arb"];
|
||||
const catalogs = arbFiles.map((file) => ({
|
||||
file,
|
||||
data: JSON.parse(readFileSync(join(sourceDir, "l10n", file), "utf8")),
|
||||
}));
|
||||
|
||||
const messageKeys = (catalog) =>
|
||||
Object.keys(catalog.data).filter((key) => !key.startsWith("@"));
|
||||
const referenceKeys = messageKeys(catalogs[0]);
|
||||
|
||||
for (const catalog of catalogs.slice(1)) {
|
||||
const keys = new Set(messageKeys(catalog));
|
||||
const missing = referenceKeys.filter((key) => !keys.has(key));
|
||||
const extra = [...keys].filter((key) => !(key in catalogs[0].data));
|
||||
if (missing.length || extra.length) {
|
||||
throw new Error(
|
||||
`${catalog.file} ARB mismatch\nmissing: ${missing.join(", ")}\nextra: ${extra.join(", ")}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (const key of referenceKeys) {
|
||||
const metadataKey = `@${key}`;
|
||||
const expected = Object.keys(
|
||||
catalogs[0].data[metadataKey]?.placeholders ?? {},
|
||||
).sort();
|
||||
for (const catalog of catalogs.slice(1)) {
|
||||
const actual = Object.keys(
|
||||
catalog.data[metadataKey]?.placeholders ?? {},
|
||||
).sort();
|
||||
if (JSON.stringify(actual) !== JSON.stringify(expected)) {
|
||||
throw new Error(`${catalog.file} placeholder mismatch for ${key}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const references = new Map();
|
||||
const directUiLiterals = [];
|
||||
const directUiPatterns = [
|
||||
/\bText\(\s*(?:const\s+)?(["'])[A-Za-z][^\r\n]*?\1/g,
|
||||
/\bTextSpan\(\s*text\s*:\s*(["'])[A-Za-z][^\r\n]*?\1/g,
|
||||
/\b(?:tooltip|hintText|labelText|helperText|errorText|semanticLabel)\s*:\s*(["'])[A-Za-z][^\r\n]*?\1/g,
|
||||
];
|
||||
function scanDirectory(directory) {
|
||||
for (const name of readdirSync(directory)) {
|
||||
const path = join(directory, name);
|
||||
if (statSync(path).isDirectory()) {
|
||||
scanDirectory(path);
|
||||
continue;
|
||||
}
|
||||
if (!name.endsWith(".dart")) continue;
|
||||
const source = readFileSync(path, "utf8");
|
||||
for (const match of source.matchAll(/(?:context\.)?l10n\.([A-Za-z_]\w*)/g)) {
|
||||
const key = match[1];
|
||||
if (["dart", "localeName"].includes(key)) continue;
|
||||
if (!references.has(key)) references.set(key, relative(mobileDir, path));
|
||||
}
|
||||
for (const pattern of directUiPatterns) {
|
||||
for (const match of source.matchAll(pattern)) {
|
||||
if (/^Text\(\s*(["'])v\$/.test(match[0])) continue;
|
||||
const line = source.slice(0, match.index).split(/\r?\n/).length;
|
||||
directUiLiterals.push(`${relative(mobileDir, path)}:${line}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
scanDirectory(sourceDir);
|
||||
|
||||
const missingReferences = [...references].filter(
|
||||
([key]) => !(key in catalogs[0].data),
|
||||
);
|
||||
if (missingReferences.length) {
|
||||
throw new Error(
|
||||
`Missing ARB messages:\n${missingReferences
|
||||
.map(([key, file]) => `${key} (${file})`)
|
||||
.join("\n")}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (directUiLiterals.length) {
|
||||
throw new Error(
|
||||
`Direct English UI literals found:\n${directUiLiterals.join("\n")}`,
|
||||
);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`l10n check passed: ${referenceKeys.length} messages, ${references.size} Dart references`,
|
||||
);
|
||||
Reference in New Issue
Block a user