Skip to content

Commit 28665aa

Browse files
committed
ci: fix translation download
1 parent 9cdecf5 commit 28665aa

File tree

4 files changed

+42
-19
lines changed

4 files changed

+42
-19
lines changed

.github/workflows/crowdin-export.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,38 @@ jobs:
1414
with:
1515
fetch-depth: 1
1616
token: ${{secrets.GITHUB_TOKEN}}
17+
1718
- name: Test using Node.js
18-
uses: actions/setup-node@v1
19+
uses: actions/setup-node@v6
1920
with:
20-
node-version: "v22"
21-
- name: Install ts-node
22-
run: npm i -g ts-node
21+
node-version: "lts/*"
22+
2323
- name: Install dependencies
2424
run: npm install
25+
2526
- name: Export translations
26-
run: ts-node --project ./tsconfig.node.json ./script/crowdin/export-translation.ts
27+
run: |
28+
npx ts-node --project ./tsconfig.node.json ./script/crowdin/export-translation.ts 2>&1 | tee /tmp/export-output.log
29+
exit ${PIPESTATUS[0]}
30+
continue-on-error: true
31+
32+
- name: Check exporting logs
33+
if: always()
34+
run: |
35+
if grep -q -F "[CROWDIN-ERROR]" /tmp/export-output.log; then
36+
echo "::error:: Found errors in export logs"
37+
exit 1
38+
else
39+
echo "No errors found in export logs"
40+
fi
41+
2742
- name: Test typescript
28-
uses: icrawl/action-tsc@v1
43+
if: success()
44+
run: npx tsc --noEmit
45+
2946
- name: Create Pull Request
30-
uses: peter-evans/create-pull-request@v7
47+
if: success()
48+
uses: peter-evans/create-pull-request@v8
3149
with:
3250
commit-message: "i18n(download): download translations by bot"
3351
branch: crowdin-export/patch

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,27 @@
3434
"@rsdoctor/rspack-plugin": "^1.5.2",
3535
"@rspack/cli": "^1.7.6",
3636
"@rspack/core": "^1.7.6",
37-
"@swc/core": "^1.15.11",
37+
"@swc/core": "^1.15.13",
3838
"@swc/jest": "^0.2.39",
39-
"@types/chrome": "0.1.36",
39+
"@types/chrome": "0.1.37",
4040
"@types/decompress": "^4.2.7",
4141
"@types/jest": "^30.0.0",
42-
"@types/node": "^25.2.3",
42+
"@types/node": "^25.3.0",
4343
"@types/punycode": "^2.1.4",
4444
"@vue/babel-plugin-jsx": "^2.0.1",
4545
"babel-loader": "^10.0.0",
46-
"commitlint": "^20.4.1",
47-
"css-loader": "^7.1.3",
46+
"commitlint": "^20.4.2",
47+
"css-loader": "^7.1.4",
4848
"decompress": "^4.2.1",
4949
"husky": "^9.1.7",
5050
"jest": "^30.2.0",
5151
"jest-environment-jsdom": "^30.2.0",
5252
"jest-junit": "^16.0.0",
5353
"jszip": "^3.10.1",
5454
"postcss": "^8.5.6",
55-
"postcss-loader": "^8.2.0",
55+
"postcss-loader": "^8.2.1",
5656
"postcss-rtlcss": "^5.7.1",
57-
"puppeteer": "^24.37.2",
57+
"puppeteer": "^24.37.5",
5858
"ts-loader": "^9.5.4",
5959
"ts-node": "^10.9.2",
6060
"tsconfig-paths": "^4.2.0",
@@ -66,9 +66,9 @@
6666
"element-plus": "2.13.2",
6767
"punycode": "^2.3.1",
6868
"vue": "^3.5.28",
69-
"vue-router": "^5.0.2"
69+
"vue-router": "^5.0.3"
7070
},
7171
"engines": {
7272
"node": ">=22"
7373
}
74-
}
74+
}

script/crowdin/common.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export async function mergeMessage(
139139
const filePath = path.join(dirPath, filename)
140140
const existMessages = (await import(`@i18n/message/${dir}/${filename}`))?.default as Messages<any>
141141
if (!existMessages) {
142-
console.error(`Failed to find local code: dir=${dir}, filename=${filename}`)
142+
logError(`Failed to find local code: dir=${dir}, filename=${filename}`)
143143
return
144144
}
145145
const sourceItemSet = transMsg(existMessages[SOURCE_LOCALE])
@@ -155,7 +155,7 @@ export async function mergeMessage(
155155
// Deleted key
156156
if (!sourceText) return
157157
if (!checkPlaceholder(text, sourceText)) {
158-
console.error(`Invalid placeholder: dir=${dir}, filename=${filename}, path=${path}, source=${sourceText}, translated=${text}`)
158+
logError(`Invalid placeholder: dir=${dir}, filename=${filename}, path=${path}, source=${sourceText}, translated=${text}`)
159159
return
160160
}
161161
const pathSeg = path.split('.')
@@ -168,6 +168,10 @@ export async function mergeMessage(
168168
fs.writeFileSync(filePath, newFileContent, { encoding: 'utf-8' })
169169
}
170170

171+
function logError(msg: string) {
172+
console.error(`[CROWDIN-ERROR] ${msg}`)
173+
}
174+
171175
function checkPlaceholder(translated: string, source: string) {
172176
const allSourcePlaceholders =
173177
Array.from(source.matchAll(/\{(.*?)\}/g))

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"DOM"
88
],
99
"types": [
10-
"jest"
10+
"jest",
11+
"chrome"
1112
],
1213
"jsx": "preserve",
1314
"jsxFactory": "h",

0 commit comments

Comments
 (0)