mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 19:50:15 +08:00
refactor crowdin init to not throw without key (#2231)
This commit is contained in:
parent
52f872b65c
commit
d11b459486
@ -1,14 +1,33 @@
|
||||
const crowdin = require("@crowdin/crowdin-api-client");
|
||||
const personalToken = process.env.CROWDIN_PERSONAL_TOKEN;
|
||||
const projectId = 531392;
|
||||
|
||||
// initialization of crowdin client
|
||||
const { translationStatusApi } = new crowdin.default({
|
||||
token: process.env.CROWDIN_PERSONAL_TOKEN,
|
||||
const initClient = async () => {
|
||||
if (!personalToken) {
|
||||
console.warn(
|
||||
"No crowding personal token, some features might not work as expected"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
return new crowdin.default({
|
||||
token: personalToken,
|
||||
});
|
||||
};
|
||||
|
||||
const client = initClient() || {};
|
||||
|
||||
async function getTranslationProgress() {
|
||||
let translationProgress = {};
|
||||
const { translationStatusApi } = client;
|
||||
|
||||
await translationStatusApi.getProjectProgress(531392).then((res) => {
|
||||
// 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user