locize-cli 8.0.2 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/bin/locize +6 -0
- package/download.js +17 -3
- package/getRemoteLanguages.js +6 -1
- package/getRemoteNamespace.js +6 -0
- package/package.json +1 -1
- package/sync.js +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
Project versioning adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
Change log format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
7
7
|
|
|
8
|
+
## [8.1.1](https://github.com/locize/locize-cli/compare/v8.1.0...v8.1.1) - 2024-10-29
|
|
9
|
+
|
|
10
|
+
- improve some error logs
|
|
11
|
+
|
|
12
|
+
## [8.1.0](https://github.com/locize/locize-cli/compare/v8.0.2...v8.1.0) - 2024-09-19
|
|
13
|
+
|
|
14
|
+
- introduce `--languages lng1,lng2` argument (#96)
|
|
15
|
+
|
|
8
16
|
## [8.0.2](https://github.com/locize/locize-cli/compare/v8.0.1...v8.0.2) - 2024-08-14
|
|
9
17
|
|
|
10
18
|
- update some dependencies to address #95 and #94
|
package/bin/locize
CHANGED
|
@@ -227,6 +227,7 @@ program
|
|
|
227
227
|
.option('-i, --project-id <projectId>', 'The project-id that should be used')
|
|
228
228
|
.option('-v, --ver <version>', 'The version that should be targeted (default: latest)')
|
|
229
229
|
.option('-l, --language <lng>', 'The language that should be targeted')
|
|
230
|
+
.option('-ls, --languages <lng1,lng2>', 'The languages that should be targeted')
|
|
230
231
|
.option('-n, --namespace <ns>', 'The namespace that should be targeted')
|
|
231
232
|
.option('-p, --path <path>', `Specify the path that should be used (default: ${process.cwd()})`, process.cwd())
|
|
232
233
|
.option('-g, --get-path <url>', `Specify the get-path url that should be used (default: ${getPathUrl})`)
|
|
@@ -253,6 +254,7 @@ program
|
|
|
253
254
|
const apiKey = options.apiKey || config.apiKey || process.env.LOCIZE_API_KEY || process.env.LOCIZE_KEY;
|
|
254
255
|
|
|
255
256
|
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG;
|
|
257
|
+
const languages = options.languages || config.languages || config.lngs || process.env.LOCIZE_LANGUAGES || process.env.LOCIZE_LANGS || process.env.LOCIZE_LNGS;
|
|
256
258
|
|
|
257
259
|
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest';
|
|
258
260
|
|
|
@@ -277,6 +279,7 @@ program
|
|
|
277
279
|
projectId: projectId,
|
|
278
280
|
apiPath: url.parse(getPath).protocol + '//' + url.parse(getPath).host,
|
|
279
281
|
language: language,
|
|
282
|
+
languages: languages && languages.split(','),
|
|
280
283
|
version: version,
|
|
281
284
|
namespace: namespace,
|
|
282
285
|
path: options.path,
|
|
@@ -370,6 +373,7 @@ program
|
|
|
370
373
|
.option('-R, --reference-language-only <true|false>', 'Check for changes in reference language only. (default: true)', 'true')
|
|
371
374
|
.option('-t, --compare-modification-time <true|false>', 'while comparing the namespace content between local and remote, take the modification time of the local file and the last modified time of the remote namespace into account. (default: false)', 'false')
|
|
372
375
|
.option('-l, --language <lng>', 'The language that should be targeted')
|
|
376
|
+
.option('-ls, --languages <lng1,lng2>', 'The languages that should be targeted')
|
|
373
377
|
.option('-n, --namespace <ns>', 'The namespace that should be targeted')
|
|
374
378
|
.option('-g, --get-path <url>', `Specify the get-path url that should be used (default: ${getPathUrl})`)
|
|
375
379
|
.option('-up, --unpublished <true|false>', 'Downloads the current (unpublished) translations. This will generate private download costs (default: false)', 'false')
|
|
@@ -398,6 +402,7 @@ program
|
|
|
398
402
|
const version = options.ver || config.ver || config.version || process.env.LOCIZE_VERSION || process.env.LOCIZE_VER || 'latest';
|
|
399
403
|
|
|
400
404
|
const language = options.language || config.language || config.lng || process.env.LOCIZE_LANGUAGE || process.env.LOCIZE_LANG || process.env.LOCIZE_LNG;
|
|
405
|
+
const languages = options.languages || config.languages || config.lngs || process.env.LOCIZE_LANGUAGES || process.env.LOCIZE_LANGS || process.env.LOCIZE_LNGS;
|
|
401
406
|
|
|
402
407
|
const namespace = options.namespace;
|
|
403
408
|
|
|
@@ -436,6 +441,7 @@ program
|
|
|
436
441
|
referenceLanguageOnly: referenceLanguageOnly,
|
|
437
442
|
compareModificationTime: compareModificationTime,
|
|
438
443
|
language: language,
|
|
444
|
+
languages: languages && languages.split(','),
|
|
439
445
|
namespace: namespace,
|
|
440
446
|
dry: dry,
|
|
441
447
|
pathMask: pathMask,
|
package/download.js
CHANGED
|
@@ -151,8 +151,22 @@ const handleError = (err, cb) => {
|
|
|
151
151
|
if (cb) cb(err);
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
+
const filterDownloadsLanguages = (opt, downloads) => {
|
|
155
|
+
if (opt.languages) {
|
|
156
|
+
downloads = downloads.filter((d) => {
|
|
157
|
+
const splitted = d.key.split('/');
|
|
158
|
+
// const p = splitted[d.isPrivate ? 1 : 0];
|
|
159
|
+
// const v = splitted[d.isPrivate ? 2 : 1];
|
|
160
|
+
const l = splitted[d.isPrivate ? 3 : 2];
|
|
161
|
+
const n = splitted[d.isPrivate ? 4 : 3];
|
|
162
|
+
return opt.languages.indexOf(l) > -1 && (!opt.namespace || opt.namespace === n);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return downloads;
|
|
166
|
+
};
|
|
167
|
+
|
|
154
168
|
const filterDownloads = (opt, downloads) => {
|
|
155
|
-
if (opt.skipEmpty) return downloads.filter((d) => d.size > 2);
|
|
169
|
+
if (opt.skipEmpty) return filterDownloadsLanguages(opt, downloads.filter((d) => d.size > 2));
|
|
156
170
|
if (downloads.length < 1) return downloads;
|
|
157
171
|
|
|
158
172
|
const allNamespaces = [];
|
|
@@ -185,7 +199,7 @@ const filterDownloads = (opt, downloads) => {
|
|
|
185
199
|
});
|
|
186
200
|
});
|
|
187
201
|
});
|
|
188
|
-
return downloads;
|
|
202
|
+
return filterDownloadsLanguages(opt, downloads);
|
|
189
203
|
};
|
|
190
204
|
|
|
191
205
|
const download = (opt, cb) => {
|
|
@@ -216,7 +230,7 @@ const download = (opt, cb) => {
|
|
|
216
230
|
|
|
217
231
|
if (opt.version) {
|
|
218
232
|
url += '/' + opt.version;
|
|
219
|
-
if (opt.language) {
|
|
233
|
+
if (!opt.languages && opt.language) {
|
|
220
234
|
url += '/' + opt.language;
|
|
221
235
|
if (opt.namespace) {
|
|
222
236
|
url += '/' + opt.namespace;
|
package/getRemoteLanguages.js
CHANGED
|
@@ -6,7 +6,12 @@ const getRemoteLanguages = (opt, cb) => {
|
|
|
6
6
|
}, (err, res, obj) => {
|
|
7
7
|
if (err || (obj && (obj.errorMessage || obj.message))) {
|
|
8
8
|
if (err) return cb(err);
|
|
9
|
-
if (obj && (obj.errorMessage || obj.message))
|
|
9
|
+
if (obj && (obj.errorMessage || obj.message)) {
|
|
10
|
+
if (res && res.statusText && res.status) {
|
|
11
|
+
return cb(new Error(res.statusText + ' (' + res.status + ') | ' + (obj.errorMessage || obj.message)));
|
|
12
|
+
}
|
|
13
|
+
return cb(new Error((obj.errorMessage || obj.message)));
|
|
14
|
+
}
|
|
10
15
|
}
|
|
11
16
|
if (res.status >= 300) return cb(new Error(res.statusText + ' (' + res.status + ')'));
|
|
12
17
|
|
package/getRemoteNamespace.js
CHANGED
|
@@ -22,6 +22,9 @@ const pullNamespacePaged = (opt, lng, ns, cb, next, retry) => {
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
if (obj && (obj.errorMessage || obj.message)) {
|
|
25
|
+
if (res.statusText && res.status) {
|
|
26
|
+
return cb(new Error(res.statusText + ' (' + res.status + ') | ' + (obj.errorMessage || obj.message)));
|
|
27
|
+
}
|
|
25
28
|
return cb(new Error((obj.errorMessage || obj.message)));
|
|
26
29
|
}
|
|
27
30
|
return cb(new Error(res.statusText + ' (' + res.status + ')'));
|
|
@@ -70,6 +73,9 @@ const getRemoteNamespace = (opt, lng, ns, cb) => {
|
|
|
70
73
|
if (err) return cb(err);
|
|
71
74
|
if (res.status >= 300) {
|
|
72
75
|
if (obj && (obj.errorMessage || obj.message)) {
|
|
76
|
+
if (res.statusText && res.status) {
|
|
77
|
+
return cb(new Error(res.statusText + ' (' + res.status + ') | ' + (obj.errorMessage || obj.message)));
|
|
78
|
+
}
|
|
73
79
|
return cb(new Error((obj.errorMessage || obj.message)));
|
|
74
80
|
}
|
|
75
81
|
return cb(new Error(res.statusText + ' (' + res.status + ')'));
|
package/package.json
CHANGED
package/sync.js
CHANGED
|
@@ -35,6 +35,9 @@ const getDownloads = (opt, cb) => {
|
|
|
35
35
|
if (err) return cb(err);
|
|
36
36
|
if (res.status >= 300) {
|
|
37
37
|
if (obj && (obj.errorMessage || obj.message)) {
|
|
38
|
+
if (res.statusText && res.status) {
|
|
39
|
+
return cb(new Error(res.statusText + ' (' + res.status + ') | ' + (obj.errorMessage || obj.message)));
|
|
40
|
+
}
|
|
38
41
|
return cb(new Error((obj.errorMessage || obj.message)));
|
|
39
42
|
}
|
|
40
43
|
return cb(new Error(res.statusText + ' (' + res.status + ')'));
|
|
@@ -48,7 +51,7 @@ const getDownloads = (opt, cb) => {
|
|
|
48
51
|
if (!res || !res[opt.version]) return handleError(new Error('Nothing found!'), cb);
|
|
49
52
|
|
|
50
53
|
const toDownload = [];
|
|
51
|
-
const lngsToCheck = opt.language ? [opt.language] : Object.keys(res[opt.version]);
|
|
54
|
+
const lngsToCheck = opt.language ? [opt.language] : (opt.languages && opt.languages.length > 0) ? opt.languages : Object.keys(res[opt.version]);
|
|
52
55
|
lngsToCheck.forEach((l) => {
|
|
53
56
|
if (opt.namespaces) {
|
|
54
57
|
opt.namespaces.forEach((n) => {
|
|
@@ -212,6 +215,7 @@ const downloadAll = (opt, remoteLanguages, omitRef, manipulate, cb) => {
|
|
|
212
215
|
opt.isPrivate = download.isPrivate;
|
|
213
216
|
|
|
214
217
|
if (opt.language && opt.language !== lng && lng !== opt.referenceLanguage) return clb(null);
|
|
218
|
+
if (opt.languages && opt.languages.length > 0 && opt.languages.indexOf(lng) < 0 && lng !== opt.referenceLanguage) return clb(null);
|
|
215
219
|
if (opt.namespace && opt.namespace !== namespace) return clb(null);
|
|
216
220
|
if (opt.namespaces && opt.namespaces.length > 0 && opt.namespaces.indexOf(namespace) < 0) return clb(null);
|
|
217
221
|
|
|
@@ -317,7 +321,7 @@ const update = (opt, lng, ns, shouldOmit, cb) => {
|
|
|
317
321
|
const cleanupLanguages = (opt, remoteLanguages) => {
|
|
318
322
|
if (opt.pathMask.lastIndexOf(path.sep) < 0) return;
|
|
319
323
|
const dirs = getDirectories(opt.path).filter((dir) => dir.indexOf('.') !== 0);
|
|
320
|
-
if (!opt.language && !opt.namespace && !opt.namespaces) {
|
|
324
|
+
if (!opt.language && (!opt.languages || opt.languages.length === 0) && !opt.namespace && !opt.namespaces) {
|
|
321
325
|
dirs
|
|
322
326
|
.filter((lng) => {
|
|
323
327
|
const lMask = `${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}`;
|
|
@@ -339,6 +343,7 @@ const cleanupLanguages = (opt, remoteLanguages) => {
|
|
|
339
343
|
}
|
|
340
344
|
remoteLanguages.forEach((lng) => {
|
|
341
345
|
if (opt.language && opt.language !== lng) return;
|
|
346
|
+
if (opt.languages && opt.languages.length > 0 && opt.languages.indexOf(lng) < 0) return;
|
|
342
347
|
const filledLngMask = opt.pathMask.replace(`${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}`, lng);
|
|
343
348
|
var lngPath;
|
|
344
349
|
if (filledLngMask.lastIndexOf(path.sep) > 0) {
|
|
@@ -583,6 +588,9 @@ const sync = (opt, cb) => {
|
|
|
583
588
|
if (opt.referenceLanguageOnly && opt.language && opt.referenceLanguage !== opt.language) {
|
|
584
589
|
opt.referenceLanguage = opt.language;
|
|
585
590
|
}
|
|
591
|
+
if (opt.referenceLanguageOnly && !opt.language && opt.languages && opt.languages.length > 0 && opt.languages.indexOf(opt.referenceLanguage) < 0) {
|
|
592
|
+
opt.referenceLanguage = opt.languages[0];
|
|
593
|
+
}
|
|
586
594
|
|
|
587
595
|
if (opt.referenceLanguageOnly) {
|
|
588
596
|
console.log(colors.grey(`checking local${opt.path !== process.cwd() ? ` (${opt.path})` : ''} only reference language...`));
|