5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 08:29:40 +08:00

feat(website): update the Crowdin branch (#2688)

This commit is contained in:
Misite Bao 2023-05-27 10:51:43 +08:00 committed by GitHub
parent 4f3dc1b0e1
commit bd5b7e5e3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 15 deletions

View File

@ -38,10 +38,10 @@ tasks:
desc: Upload source files to Crowdin
deps: [install]
cmds:
- npx crowdin push -b master
- npx crowdin push -b v2
crowdin:pull:
desc: Download approved translation files from Crowdin to local
deps: [install]
cmds:
- npx crowdin pull -b master --export-only-approved
- npx crowdin pull -b v2 --export-only-approved

View File

@ -1,4 +1,4 @@
project_id: 531392
project_id: "531392"
api_token_env: CROWDIN_PERSONAL_TOKEN
preserve_hierarchy: true
commit_message: "[ci skip]"

View File

@ -11,9 +11,7 @@
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"crowdin": "crowdin",
"crowdin:sync": "docusaurus write-translations && crowdin upload && crowdin download"
"write-heading-ids": "docusaurus write-heading-ids"
},
"engines": {
"node": ">=18.14.0",

View File

@ -1,6 +1,7 @@
const crowdin = require("@crowdin/crowdin-api-client");
const personalToken = process.env.CROWDIN_PERSONAL_TOKEN;
const projectId = 531392;
const projectId = "531392";
const branch = "v2";
// initialization of crowdin client
const initClient = () => {
@ -16,22 +17,34 @@ const initClient = () => {
});
};
const client = initClient() || {};
async function getTranslationProgress() {
let translationProgress = {};
const { translationStatusApi } = client;
const client = initClient() || {};
const { sourceFilesApi, translationStatusApi } = client;
// do nothing if client failed to init
if (!translationStatusApi) {
return translationProgress;
}
await translationStatusApi.getProjectProgress(projectId).then((res) => {
for (const item of res.data) {
translationProgress[item.data.languageId] = item.data.approvalProgress;
}
});
const branchId = await sourceFilesApi
.listProjectBranches(projectId)
.then((res) => {
for (const item of res.data) {
if (item.data.name == branch) {
return item.data.id;
}
}
});
await translationStatusApi
.getBranchProgress(projectId, branchId)
.then((res) => {
for (const item of res.data) {
translationProgress[item.data.languageId] = item.data.approvalProgress;
}
});
return translationProgress;
}