locize-cli 8.0.2 → 8.1.0
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 +4 -0
- package/bin/locize +6 -0
- package/download.js +17 -3
- package/package.json +1 -1
- package/sync.js +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ 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.0](https://github.com/locize/locize-cli/compare/v8.0.2...v8.1.0) - 2024-09-19
|
|
9
|
+
|
|
10
|
+
- introduce `--languages lng1,lng2` argument (#96)
|
|
11
|
+
|
|
8
12
|
## [8.0.2](https://github.com/locize/locize-cli/compare/v8.0.1...v8.0.2) - 2024-08-14
|
|
9
13
|
|
|
10
14
|
- 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/package.json
CHANGED
package/sync.js
CHANGED
|
@@ -48,7 +48,7 @@ const getDownloads = (opt, cb) => {
|
|
|
48
48
|
if (!res || !res[opt.version]) return handleError(new Error('Nothing found!'), cb);
|
|
49
49
|
|
|
50
50
|
const toDownload = [];
|
|
51
|
-
const lngsToCheck = opt.language ? [opt.language] : Object.keys(res[opt.version]);
|
|
51
|
+
const lngsToCheck = opt.language ? [opt.language] : (opt.languages && opt.languages.length > 0) ? opt.languages : Object.keys(res[opt.version]);
|
|
52
52
|
lngsToCheck.forEach((l) => {
|
|
53
53
|
if (opt.namespaces) {
|
|
54
54
|
opt.namespaces.forEach((n) => {
|
|
@@ -212,6 +212,7 @@ const downloadAll = (opt, remoteLanguages, omitRef, manipulate, cb) => {
|
|
|
212
212
|
opt.isPrivate = download.isPrivate;
|
|
213
213
|
|
|
214
214
|
if (opt.language && opt.language !== lng && lng !== opt.referenceLanguage) return clb(null);
|
|
215
|
+
if (opt.languages && opt.languages.length > 0 && opt.languages.indexOf(lng) < 0 && lng !== opt.referenceLanguage) return clb(null);
|
|
215
216
|
if (opt.namespace && opt.namespace !== namespace) return clb(null);
|
|
216
217
|
if (opt.namespaces && opt.namespaces.length > 0 && opt.namespaces.indexOf(namespace) < 0) return clb(null);
|
|
217
218
|
|
|
@@ -317,7 +318,7 @@ const update = (opt, lng, ns, shouldOmit, cb) => {
|
|
|
317
318
|
const cleanupLanguages = (opt, remoteLanguages) => {
|
|
318
319
|
if (opt.pathMask.lastIndexOf(path.sep) < 0) return;
|
|
319
320
|
const dirs = getDirectories(opt.path).filter((dir) => dir.indexOf('.') !== 0);
|
|
320
|
-
if (!opt.language && !opt.namespace && !opt.namespaces) {
|
|
321
|
+
if (!opt.language && (!opt.languages || opt.languages.length === 0) && !opt.namespace && !opt.namespaces) {
|
|
321
322
|
dirs
|
|
322
323
|
.filter((lng) => {
|
|
323
324
|
const lMask = `${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}`;
|
|
@@ -339,6 +340,7 @@ const cleanupLanguages = (opt, remoteLanguages) => {
|
|
|
339
340
|
}
|
|
340
341
|
remoteLanguages.forEach((lng) => {
|
|
341
342
|
if (opt.language && opt.language !== lng) return;
|
|
343
|
+
if (opt.languages && opt.languages.length > 0 && opt.languages.indexOf(lng) < 0) return;
|
|
342
344
|
const filledLngMask = opt.pathMask.replace(`${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}`, lng);
|
|
343
345
|
var lngPath;
|
|
344
346
|
if (filledLngMask.lastIndexOf(path.sep) > 0) {
|
|
@@ -583,6 +585,9 @@ const sync = (opt, cb) => {
|
|
|
583
585
|
if (opt.referenceLanguageOnly && opt.language && opt.referenceLanguage !== opt.language) {
|
|
584
586
|
opt.referenceLanguage = opt.language;
|
|
585
587
|
}
|
|
588
|
+
if (opt.referenceLanguageOnly && !opt.language && opt.languages && opt.languages.length > 0 && opt.languages.indexOf(opt.referenceLanguage) < 0) {
|
|
589
|
+
opt.referenceLanguage = opt.languages[0];
|
|
590
|
+
}
|
|
586
591
|
|
|
587
592
|
if (opt.referenceLanguageOnly) {
|
|
588
593
|
console.log(colors.grey(`checking local${opt.path !== process.cwd() ? ` (${opt.path})` : ''} only reference language...`));
|