locize-cli 10.1.1 → 10.2.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 CHANGED
@@ -5,6 +5,15 @@ 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
+
9
+ ## [10.2.1](https://github.com/locize/locize-cli/compare/v10.2.0...v10.2.1) - 2025-08-07
10
+
11
+ - download/sync: check if branch name is empty string
12
+
13
+ ## [10.2.0](https://github.com/locize/locize-cli/compare/v10.1.1...v10.2.0) - 2025-07-16
14
+
15
+ - download/sync introduce `--overridden-only` option for branches or tenants
16
+
8
17
  ## [10.1.1](https://github.com/locize/locize-cli/compare/v10.1.0...v10.1.1) - 2025-07-12
9
18
 
10
19
  - create-branch: nicer feedback, if branch already exists
package/README.md CHANGED
@@ -23,6 +23,23 @@ iwr https://raw.githubusercontent.com/locize/locize-cli/master/install.ps1 -useb
23
23
  ```
24
24
 
25
25
 
26
+ > ⚠️ **Filename restrictions**
27
+ > The namespace you choose becomes your on-disk filename, so please avoid these characters:
28
+ > ```
29
+ > < (less than)
30
+ > > (greater than)
31
+ > : (colon)
32
+ > " (double quote)
33
+ > / (forward slash)
34
+ > \ (backslash)
35
+ > | (vertical bar or pipe)
36
+ > ? (question mark)
37
+ > * (asterisk)
38
+ > ```
39
+ > These are sometimes illegal on various operating systems, so using them may lead to files not being written or being written incorrectly. If necessary, use only letters, numbers, hyphens ("-") and underscores ("_") in your namespace names.
40
+
41
+
42
+
26
43
  ## Adding/Updating new keys
27
44
  ### Step 1: execute
28
45
 
package/bin/locize CHANGED
@@ -241,6 +241,7 @@ program
241
241
  .option('-m, --path-mask <mask>', 'This will define the folder and file structure; do not add a file extension (default: {{language}}/{{namespace}})', `{{language}}${path.sep}{{namespace}}`)
242
242
  .option('-c, --clean <true|false>', 'Removes all local files by removing the whole folder (default: false)', 'false')
243
243
  .option('-up, --unpublished <true|false>', 'Downloads the current (unpublished) translations. This will generate private download costs (default: false)', 'false')
244
+ .option('-oo, --overridden-only <true|false>', 'Downloads only the current overridden (unpublished) translations of a tenant or branch project. This will generate private download costs (default: false)', 'false')
244
245
  .option('-b, --branch <branch>', 'The branch name (or id) that should be targeted')
245
246
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
246
247
  .action((options) => {
@@ -274,6 +275,8 @@ program
274
275
 
275
276
  const unpublished = options.unpublished === 'true';
276
277
 
278
+ const overriddenOnly = options.overriddenOnly === 'true';
279
+
277
280
  const languageFolderPrefix = options.languageFolderPrefix || '';
278
281
 
279
282
  const pathMask = options.pathMask;
@@ -295,7 +298,8 @@ program
295
298
  languageFolderPrefix: languageFolderPrefix,
296
299
  pathMask: pathMask,
297
300
  unpublished: unpublished,
298
- branch: branch
301
+ branch: branch,
302
+ overriddenOnly: overriddenOnly
299
303
  });
300
304
  })
301
305
  .on('--help', () => {
@@ -386,6 +390,7 @@ program
386
390
  .option('-n, --namespace <ns>', 'The namespace that should be targeted (you can also pass a comma separated list)')
387
391
  .option('-g, --get-path <url>', `Specify the get-path url that should be used (default: ${getPathUrl})`)
388
392
  .option('-up, --unpublished <true|false>', 'Downloads the current (unpublished) translations. This will generate private download costs (default: false)', 'false')
393
+ .option('-oo, --overridden-only <true|false>', 'Downloads only the current overridden (unpublished) translations of a tenant or branch project. This will generate private download costs (default: false)', 'false')
389
394
  .option('-b, --branch <branch>', 'The branch name (or id) that should be targeted')
390
395
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
391
396
  .action((options) => {
@@ -433,6 +438,7 @@ program
433
438
  const compareModificationTime = options.compareModificationTime === 'true';
434
439
  const pathMask = options.pathMask;
435
440
  const unpublished = options.unpublished === 'true';
441
+ const overriddenOnly = options.overriddenOnly === 'true';
436
442
  const autoCreatePath = options.autoCreatePath === 'true';
437
443
  const backupDeletedPath = options.backupDeletedPath;
438
444
  const branch = options.branch;
@@ -462,7 +468,8 @@ program
462
468
  unpublished: unpublished,
463
469
  autoCreatePath: autoCreatePath,
464
470
  backupDeletedPath: backupDeletedPath,
465
- branch: branch
471
+ branch: branch,
472
+ overriddenOnly: overriddenOnly
466
473
  });
467
474
  })
468
475
  .on('--help', () => {
package/download.js CHANGED
@@ -467,10 +467,17 @@ const download = (opt, cb) => {
467
467
  opt.pathMaskInterpolationSuffix = opt.pathMaskInterpolationSuffix || '}}';
468
468
  opt.pathMask = opt.pathMask || `${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}${path.sep}${opt.pathMaskInterpolationPrefix}namespace${opt.pathMaskInterpolationSuffix}`;
469
469
  opt.pathMask = opt.pathMask.replace(`${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}`, `${opt.languageFolderPrefix}${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}`);
470
+ if (opt.overriddenOnly) {
471
+ opt.unpublished = true;
472
+ }
470
473
  if (opt.unpublished && !opt.apiKey) {
471
474
  return handleError(new Error('Please provide also an api-key!'), cb);
472
475
  }
473
476
 
477
+ if (opt.branch === '') {
478
+ return handleError(new Error('The branch name seems invalid!'), cb);
479
+ }
480
+
474
481
  if (opt.branch) {
475
482
  getBranches(opt, (err, branches) => {
476
483
  if (err) return handleError(err, cb);
@@ -23,7 +23,7 @@ function onlyKeysFlat(resources, prefix, ret) {
23
23
 
24
24
  const pullNamespacePaged = (opt, lng, ns, cb, next, retry) => {
25
25
  next = next || '';
26
- request(opt.apiPath + '/pull/' + opt.projectId + '/' + opt.version + '/' + lng + '/' + ns + '?' + 'next=' + next + (opt.raw ? '&raw=true' : '') + '&ts=' + Date.now(), {
26
+ request(opt.apiPath + '/pull/' + opt.projectId + '/' + opt.version + '/' + lng + '/' + ns + '?' + 'next=' + next + ((opt.raw || opt.overriddenOnly) ? '&raw=true' : '') + '&ts=' + Date.now(), {
27
27
  method: 'get',
28
28
  headers: {
29
29
  'Authorization': opt.apiKey
@@ -47,6 +47,20 @@ const pullNamespacePaged = (opt, lng, ns, cb, next, retry) => {
47
47
  return cb(new Error(res.statusText + ' (' + res.status + ')'));
48
48
  }
49
49
 
50
+ if (opt.overriddenOnly && obj) {
51
+ const newObj = {};
52
+ Object.keys(obj).forEach((k) => {
53
+ if (obj[k].overrides !== undefined) {
54
+ if (opt.raw) {
55
+ newObj[k] = obj[k];
56
+ } else {
57
+ newObj[k] = obj[k].value;
58
+ }
59
+ }
60
+ });
61
+ obj = newObj;
62
+ }
63
+
50
64
  cb(null, {
51
65
  result: opt.raw ? sortFlatResources(onlyKeysFlat(obj)) : sortFlatResources(flatten(obj)),
52
66
  next: res.headers.get('x-next-page'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "10.1.1",
3
+ "version": "10.2.1",
4
4
  "description": "locize cli to import locales",
5
5
  "main": "index.js",
6
6
  "bin": {
package/sync.js CHANGED
@@ -736,10 +736,17 @@ const sync = (opt, cb) => {
736
736
  opt.pathMask = opt.pathMask || `${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}${path.sep}${opt.pathMaskInterpolationPrefix}namespace${opt.pathMaskInterpolationSuffix}`;
737
737
  opt.languageFolderPrefix = opt.languageFolderPrefix || '';
738
738
  opt.pathMask = opt.pathMask.replace(`${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}`, `${opt.languageFolderPrefix}${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}`);
739
+ if (opt.overriddenOnly) {
740
+ opt.unpublished = true;
741
+ }
739
742
  if (opt.unpublished && !opt.apiKey) {
740
743
  return handleError(new Error('Please provide also an api-key!'), cb);
741
744
  }
742
745
 
746
+ if (opt.branch === '') {
747
+ return handleError(new Error('The branch name seems invalid!'), cb);
748
+ }
749
+
743
750
  if (opt.branch) {
744
751
  getBranches(opt, (err, branches) => {
745
752
  if (err) return handleError(err, cb);