locize-cli 7.15.2 → 8.0.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,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.0.1](https://github.com/locize/locize-cli/compare/v8.0.0...v8.0.1) - 2023-04-10
9
+
10
+ - update some dependencies to address security vulnerabilities in xlsx
11
+
12
+ ## [8.0.0](https://github.com/locize/locize-cli/compare/v7.15.2...v8.0.0) - 2023-01-18
13
+
14
+ - align json format with publish format on project: To keep the same behaviour like before with default format or `json` format, now use `--format nested`. The `--format json` (the default) will now try to "guess" if a flat or a nested format should be used.
15
+
8
16
  ## [7.15.2](https://github.com/locize/locize-cli/compare/v7.15.1...v7.15.2) - 2023-01-06
9
17
 
10
18
  - optimize --skip-empty false handling for download command
package/README.md CHANGED
@@ -66,6 +66,9 @@ locize get common title
66
66
 
67
67
 
68
68
  ## Download current published files
69
+
70
+ *The CLI will use the normal [API](https://docs.locize.com/integration/api) endpoints to download the translations, so normal download charges etc. will occur.*
71
+
69
72
  ### Step 1: execute
70
73
 
71
74
  Add your project-id and let's go...
@@ -81,7 +84,7 @@ or
81
84
  locize download
82
85
  ```
83
86
 
84
- or add a format like (json, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties)
87
+ or add a format like (json, nested, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties)
85
88
 
86
89
  ```sh
87
90
  locize download --project-id my-project-id-93e1-442a-ab35-24331fa294ba --ver latest --language en --namespace namespace1 --path ./backup --format android
@@ -98,6 +101,10 @@ An example on how this could look like can be seen in [this tutorial](https://gi
98
101
 
99
102
  **⚠️ Since the remote source are the published translations, make sure the desired version is set to auto publish mode. Alternatively use the `--unpublished true` argument (this will generate [private downloads costs](https://docs.locize.com/integration/api#fetch-filter-the-unpublished-namespace-resources)). ⚠️**
100
103
 
104
+ *The CLI will use the normal [API](https://docs.locize.com/integration/api) endpoints, so normal modification and download charges etc. will occur.*
105
+
106
+ *If you need to change or remove multiple keys, please do NOT execute the sync command after each individual key change, but make the changes all together and then execute the sync command once.*
107
+
101
108
  ### Step 1: Go near to your translation files
102
109
 
103
110
  ```sh
@@ -126,7 +133,7 @@ Add your api-key and your project-id and let's go...
126
133
  locize sync --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba
127
134
  ```
128
135
 
129
- or add a format like (json, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties)
136
+ or add a format like (json, nested, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties)
130
137
 
131
138
  ```sh
132
139
  locize sync --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba --format android
@@ -184,7 +191,7 @@ Add your api-key and your project-id and let's go...
184
191
  locize save-missing --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba
185
192
  ```
186
193
 
187
- or add a format like (json, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties)
194
+ or add a format like (json, nested, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties)
188
195
 
189
196
  ```sh
190
197
  locize save-missing --api-key my-api-key-d9de-4f55-9855-a9ef0ed44672 --project-id my-project-id-93e1-442a-ab35-24331fa294ba --format android
package/bin/locize CHANGED
@@ -231,7 +231,7 @@ program
231
231
  .option('-p, --path <path>', `Specify the path that should be used (default: ${process.cwd()})`, process.cwd())
232
232
  .option('-g, --get-path <url>', `Specify the get-path url that should be used (default: ${getPathUrl})`)
233
233
  .option('-k, --api-key <apiKey>', 'The api-key that should be used')
234
- .option('-f, --format <json>', 'File format of namespaces (default: json; [flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties])', 'json')
234
+ .option('-f, --format <json>', 'File format of namespaces (default: json; [nested, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties])', 'json')
235
235
  .option('-s, --skip-empty <true|false>', 'Skips to download empty files (default: true)', 'true')
236
236
  .option('-P, --language-folder-prefix <prefix>', 'This will be added as a local folder name prefix in front of the language.', '')
237
237
  .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}}`)
@@ -357,7 +357,7 @@ program
357
357
  .option('-v, --ver <version>', 'Found namespaces will be matched to this version (default: latest)')
358
358
  .option('-p, --path <path>', `Specify the path that should be used (default: ${process.cwd()})`, process.cwd())
359
359
  .option('-A, --auto-create-path <true|false>', 'This will automatically make sure the --path is created. (default: true)', 'true')
360
- .option('-f, --format <json>', 'File format of namespaces (default: json; [flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties])', 'json')
360
+ .option('-f, --format <json>', 'File format of namespaces (default: json; [nested, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties])', 'json')
361
361
  .option('-s, --skip-empty <true|false>', 'Skips to download empty files (default: false)', 'false')
362
362
  .option('-c, --clean <true|false>', 'Removes all local files by removing the whole folder (default: false)', 'false')
363
363
  .option('-cf, --clean-local-files <true|false>', 'Removes all local files without removing any folder (default: false)', 'false')
@@ -460,7 +460,7 @@ program
460
460
  .option('-i, --project-id <projectId>', 'The project-id that should be used')
461
461
  .option('-v, --ver <version>', 'Found namespaces will be matched to this version (default: latest)')
462
462
  .option('-p, --path <path>', `Specify the path that should be used (default: ${process.cwd()})`, process.cwd())
463
- .option('-f, --format <json>', 'File format of namespaces (default: json; [flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties])', 'json')
463
+ .option('-f, --format <json>', 'File format of namespaces (default: json; [nested, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties])', 'json')
464
464
  .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}}`)
465
465
  .option('-P, --language-folder-prefix <prefix>', 'This will be added as a local folder name prefix in front of the language.', '')
466
466
  .option('-d, --dry <true|false>', 'Dry run (default: false)', 'false')
@@ -679,7 +679,7 @@ program
679
679
  .command('format [fileOrDirectory]')
680
680
  .alias('ft')
681
681
  .description('format local files')
682
- .option('-f, --format <json>', 'File format of namespaces (default: json; [flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties])', 'json')
682
+ .option('-f, --format <json>', 'File format of namespaces (default: json; [nested, flat, xliff2, xliff12, xlf2, xlf12, android, yaml, yaml-rails, yaml-nested, csv, xlsx, po, strings, resx, fluent, tmx, laravel, properties])', 'json')
683
683
  .option('-l, --reference-language <lng>', 'Some format conversions need to know the reference language.', 'en')
684
684
  .option('-d, --dry <true|false>', 'Dry run (default: false)', 'false')
685
685
  .option('-C, --config-path <configPath>', `Specify the path to the optional locize config file (default: ${configInWorkingDirectory} or ${configInHome})`)
@@ -30,6 +30,13 @@ const convertToDesiredFormat = (
30
30
  const isEmpty = !data || Object.keys(data).length === 0;
31
31
  try {
32
32
  if (opt.format === 'json') {
33
+ try {
34
+ data = unflatten(data, true);
35
+ } catch (err) {}
36
+ cb(null, JSON.stringify(data, null, 2));
37
+ return;
38
+ }
39
+ if (opt.format === 'nested') {
33
40
  try {
34
41
  data = unflatten(data);
35
42
  } catch (err) {}
@@ -22,7 +22,7 @@ const convertToFlatFormat = (opt, data, lng, cb) => {
22
22
  lng = undefined;
23
23
  }
24
24
  try {
25
- if (opt.format === 'json' || opt.format === 'flat') {
25
+ if (opt.format === 'json' || opt.format === 'nested' || opt.format === 'flat') {
26
26
  const dataString = data.toString().trim();
27
27
  if (dataString[0] !== '{' && dataString[0] !== '[') {
28
28
  return cb(new Error(`Not a valid json file: Content starts with "${dataString[0]}" but should start with "{"`));
package/formats.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const fileExtensionsMap = {
2
- '.json': ['json', 'flat'],
2
+ '.json': ['json', 'nested', 'flat'],
3
3
  '.po': ['po', 'gettext', 'po_i18next', 'gettext_i18next'],
4
4
  '.xml': ['android'],
5
5
  '.strings': ['strings'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "7.15.2",
3
+ "version": "8.0.1",
4
4
  "description": "locize cli to import locales",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -14,13 +14,13 @@
14
14
  "colors": "1.4.0",
15
15
  "commander": "9.5.0",
16
16
  "csvjson": "5.1.0",
17
- "diff": "5.1.0",
18
- "dotenv": "16.3.1",
17
+ "diff": "5.2.0",
18
+ "dotenv": "16.4.5",
19
19
  "flat": "5.0.2",
20
- "fluent_conv": "3.2.0",
21
- "gettext-converter": "1.2.4",
20
+ "fluent_conv": "3.3.0",
21
+ "gettext-converter": "1.3.0",
22
22
  "https-proxy-agent": "5.0.1",
23
- "ini": "4.1.1",
23
+ "ini": "4.1.2",
24
24
  "js-yaml": "4.1.0",
25
25
  "laravelphp": "2.0.4",
26
26
  "lodash.clonedeep": "4.5.0",
@@ -30,8 +30,8 @@
30
30
  "rimraf": "3.0.2",
31
31
  "strings-file": "0.0.5",
32
32
  "tmexchange": "2.0.5",
33
- "xliff": "6.2.0",
34
- "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.0/xlsx-0.20.0.tgz"
33
+ "xliff": "6.2.1",
34
+ "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"
35
35
  },
36
36
  "devDependencies": {
37
37
  "eslint": "8.56.0",
package/unflatten.js CHANGED
@@ -1,8 +1,13 @@
1
- module.exports = (data) => {
1
+ module.exports = (data, testNatural) => {
2
2
  const result = {};
3
3
  const shouldConvertArray = {};
4
- for (var i in data) {
5
- const keys = i.split('.');
4
+ for (const i in data) {
5
+ let keys = [];
6
+ if (testNatural && /( |,|\?)/.test(i)) {
7
+ keys = [i];
8
+ } else {
9
+ keys = i.split('.');
10
+ }
6
11
  keys.reduce((r, e, j) => {
7
12
  const isNumber = !isNaN(Number(keys[j + 1]));
8
13
  const hasLeadingZero = isNumber && keys[j + 1].length > 1 && keys[j + 1][0] === '0';