mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 04:09:46 +08:00
feat(website): update the Crowdin
branch (#2688)
This commit is contained in:
parent
4f3dc1b0e1
commit
bd5b7e5e3f
@ -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
|
||||
|
@ -1,4 +1,4 @@
|
||||
project_id: 531392
|
||||
project_id: "531392"
|
||||
api_token_env: CROWDIN_PERSONAL_TOKEN
|
||||
preserve_hierarchy: true
|
||||
commit_message: "[ci skip]"
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user