Skip to content

Commit d0ab618

Browse files
committed
🌐 处理翻译问题
1 parent 08863ad commit d0ab618

18 files changed

Lines changed: 1239 additions & 558 deletions

File tree

build/crowdin-download.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { execSync } from "child_process";
2+
import { readdirSync, statSync, readFileSync, writeFileSync } from "fs";
3+
import { join } from "path";
4+
5+
// 执行 crowdin download --skip-untranslated-strings
6+
execSync("crowdin download --skip-untranslated-strings", { stdio: "inherit" });
7+
8+
// 将所有语言中的""删除
9+
// 语言文件在 src/locales/*/*.json 排除zh-CN
10+
const localesPath = "./src/locales";
11+
function removeEmptyStringsFromLocaleFiles(dir) {
12+
const files = readdirSync(dir);
13+
files.forEach((file) => {
14+
const filePath = join(dir, file);
15+
if (statSync(filePath).isDirectory() && !filePath.includes("zh-CN")) {
16+
removeEmptyStringsFromLocaleFiles(filePath);
17+
} else if (file.endsWith(".json")) {
18+
const content = JSON.parse(readFileSync(filePath, "utf-8"));
19+
for (const key in content) {
20+
if (content[key] === "") {
21+
delete content[key];
22+
}
23+
}
24+
writeFileSync(filePath, JSON.stringify(content, null, 2));
25+
}
26+
});
27+
}
28+
removeEmptyStringsFromLocaleFiles(localesPath);

package-lock.json

Lines changed: 209 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scriptcat",
3-
"version": "0.16.10",
3+
"version": "0.16.11-beta",
44
"description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!",
55
"author": "CodFrm",
66
"license": "GPLv3",
@@ -20,6 +20,7 @@
2020
},
2121
"dependencies": {
2222
"@arco-design/web-react": "^2.51.1",
23+
"@crowdin/cli": "^4.9.0",
2324
"@dnd-kit/core": "^6.0.5",
2425
"@dnd-kit/sortable": "^7.0.1",
2526
"@dnd-kit/utilities": "^3.2.0",

0 commit comments

Comments
 (0)