@enplug/scripts
Advanced tools
@@ -241,12 +241,11 @@ const axios = require('axios'); | ||
function fetchFileFromCrowdin(credentials, crowdinPath, language) { | ||
const url = `${CROWDIN_PROJECT_URL}/export-file`; | ||
const params = { | ||
'login': credentials.login, | ||
'account-key': credentials.accountKey, | ||
'file': crowdinPath, | ||
'language': language | ||
function fetchFileFromCrowdin(credentials, language, fileId) { | ||
const url = `${CROWDIN_PROJECT_URL}/translations/exports`; | ||
const AuthStr = 'Bearer '.concat(credentials.token); | ||
const body = { | ||
"targetLanguageId": language, | ||
"fileIds": [fileId] | ||
}; | ||
return axios.get(url, { params }); | ||
return axios.post(url, body, { headers: { Authorization: AuthStr } }); | ||
} | ||
@@ -253,0 +252,0 @@ |
@@ -87,3 +87,3 @@ const chalk = require('chalk'); | ||
if(fileId && storageId) { | ||
updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId); | ||
await updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId); | ||
} | ||
@@ -93,3 +93,4 @@ } else { | ||
if(storageId) { | ||
addCrowdinFile(credentials, crowdinPath, storageId.data.data.id, folderId); | ||
const result = await addCrowdinFile(credentials, crowdinPath, storageId.data.data.id, folderId); | ||
console.log('add result', result.data); | ||
} | ||
@@ -103,3 +104,3 @@ } | ||
if(fileId && storageId) { | ||
updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId); | ||
await updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId); | ||
} | ||
@@ -117,12 +118,13 @@ } else { | ||
if(fileId && storageId) { | ||
updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId); | ||
await updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId); | ||
} | ||
} | ||
} | ||
// await uploadFileToCrowdin(credentials, config.crowdinPath, config.localPath); | ||
// const { data: fakeTranslation } = await fetchFileFromCrowdin(credentials, config.crowdinPath, FAKE_IN_CONTEXT_LANGUAGE); | ||
const { data: fakeTranslation } = await fetchFileFromCrowdin(credentials, FAKE_IN_CONTEXT_LANGUAGE, fileId); | ||
console.log('eo data', fakeTranslation); | ||
const s3TranslationsPath = path.parse(s3EnPath).dir; | ||
console.log('s3TranslationsPath', s3TranslationsPath); | ||
const s3FakeTranslationPath = path.join(s3TranslationsPath, FAKE_IN_CONTEXT_LANGUAGE_FILE); | ||
console.log('s3FakeTranslationPath', s3FakeTranslationPath); | ||
// const s3TranslationsPath = path.parse(s3EnPath).dir; | ||
// const s3FakeTranslationPath = path.join(s3TranslationsPath, FAKE_IN_CONTEXT_LANGUAGE_FILE); | ||
// await uploadTranslationToS3(s3Client, bucket, s3FakeTranslationPath, JSON.stringify(fakeTranslation)); | ||
@@ -129,0 +131,0 @@ } |
{ | ||
"name": "@enplug/scripts", | ||
"version": "1.11.4-dev58", | ||
"version": "1.11.4-dev59", | ||
"description": "Enplug scripts", | ||
@@ -5,0 +5,0 @@ "scripts": { |
103759
0.18%2536
0.08%