mirror of
https://github.com/go-task/task.git
synced 2026-06-23 20:55:52 +00:00
feat(website): add translation progress
Closes #1173 Closes #1170 Closes #1102
This commit is contained in:
committed by
Andrey Nering
parent
3eab444c03
commit
785fc4ac3c
50
docs/src/api/crowdin.js
Normal file
50
docs/src/api/crowdin.js
Normal file
@@ -0,0 +1,50 @@
|
||||
const crowdin = require('@crowdin/crowdin-api-client');
|
||||
const personalToken = process.env.CROWDIN_PERSONAL_TOKEN;
|
||||
const projectId = '574591';
|
||||
|
||||
/**
|
||||
* Initialization of crowdin client
|
||||
* @return {object} crowdin client
|
||||
*/
|
||||
const initClient = () => {
|
||||
if (!personalToken) {
|
||||
console.warn(
|
||||
'No crowding personal token, some features might not work as expected'
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new crowdin.default({
|
||||
token: personalToken
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get translation progress
|
||||
* @return {object} translation progress
|
||||
*/
|
||||
async function getTranslationProgress() {
|
||||
let translationProgress = {};
|
||||
const { translationStatusApi } = initClient() || {};
|
||||
|
||||
if (!translationStatusApi) {
|
||||
return translationProgress;
|
||||
}
|
||||
|
||||
await translationStatusApi
|
||||
.getProjectProgress(projectId)
|
||||
.then((res) => {
|
||||
res.data.forEach((item) => {
|
||||
translationProgress[item.data.languageId] = item.data.approvalProgress;
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
return translationProgress;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getTranslationProgress
|
||||
};
|
||||
Reference in New Issue
Block a user