Skip to content

Commit 628126e

Browse files
committed
feat: add syncTerms & defaultLang options
1 parent df4e01d commit 628126e

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
`2021-09-02`
44

55
- 🌟 Added possibility to pass custom parameters to pull or push API requests
6+
- 🌟 Added syncTerms option support
67

78
## 1.14.0
89

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Create a **poeditor-config.json** in the root directory, and config information
3838
"projectId": 0, // project id
3939
"fileType": "", // fileType to upload or download, supports files format (po, pot, mo, xls, csv, resw, resx, android_strings, apple_strings, xliff, properties, key_value_json, json, xmb, xtb)
4040
"targetDir": "", // directory where translated files live
41+
"syncTerms": true, // (optional) set it to true if you want to sync your terms (terms that are not found in the uploaded file will be deleted from project and the new ones added)
42+
"sourceLang": "en-US", // (optional, required when syncTerms set to true) language to sync the terms from
4143
"pullParams": {}, // (optional) allows to pass any parameters available on the POEditor's export endpoint, full list here: https://poeditor.com/docs/api#projects_export
4244
"pushParams": {} // (optional) allows to pass any parameters available on the POEditor's upload endpoint, full list here: https://poeditor.com/docs/api#projects_upload
4345
}

packages/commands/push.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ async function putTermFile(config) {
120120
formData.append("updating", "terms_translations");
121121
formData.append("file", fs.createReadStream(config.file));
122122
formData.append("overwrite", "1");
123+
124+
if (config.syncTerms && config.sourceLang && config.language === config.sourceLang) {
125+
formData.append('sync_terms', '1');
126+
}
127+
123128
if (config.pushParams) {
124129
Object.keys(config.pushParams)
125130
.forEach(paramName => formData.set(paramName, config.pushParams[paramName]))

0 commit comments

Comments
 (0)