locize-cli 9.0.0 → 9.0.2

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
+ ## [9.0.2](https://github.com/locize/locize-cli/compare/v9.0.1...v9.0.2) - 2025-04-25
9
+
10
+ - Hint: `Using the "--auto-translate true" option together with the "--reference-language-only false" option might result in inconsistent target language translations (automatic translation vs. what is sent direcly to locize).`
11
+
12
+ ## [9.0.1](https://github.com/locize/locize-cli/compare/v9.0.0...v9.0.1) - 2025-04-04
13
+
14
+ - optimize xcstrings format [106](https://github.com/locize/locize-cli/issues/106)
15
+
8
16
  ## [9.0.0](https://github.com/locize/locize-cli/compare/v8.7.1...v9.0.0) - 2025-04-03
9
17
 
10
18
  - the format `yaml-rails-ns`/`yml-rails-ns` is the old `yaml-rails`/`yml-rails`
package/download.js CHANGED
@@ -79,8 +79,7 @@ function handleDownload(opt, url, err, res, downloads, cb) {
79
79
  if (err) return clb(err);
80
80
 
81
81
  try {
82
- const result = locize2xcstrings(locizeData);
83
- const converted = JSON.stringify(result, null, 2);
82
+ const converted = locize2xcstrings(locizeData);
84
83
 
85
84
  var filledMask = opt.pathMask.replace(`${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}`, '').replace(`${opt.pathMaskInterpolationPrefix}namespace${opt.pathMaskInterpolationSuffix}`, ns) + reversedFileExtensionsMap[opt.format];
86
85
  var mkdirPath;
@@ -94,7 +93,7 @@ function handleDownload(opt, url, err, res, downloads, cb) {
94
93
  if (clb) clb(null);
95
94
  }
96
95
 
97
- const fileContent = opt.format !== 'xlsx' ? (converted + '\n') : converted;
96
+ const fileContent = (opt.format !== 'xlsx' && !converted.endsWith('\n')) ? (converted + '\n') : converted;
98
97
  if (!opt.version) {
99
98
  if (mkdirPath) mkdirp.sync(path.join(opt.path, version, mkdirPath));
100
99
  fs.writeFile(path.join(opt.path, version, filledMask), fileContent, logAndClb);
@@ -146,7 +145,7 @@ function handleDownload(opt, url, err, res, downloads, cb) {
146
145
  if (filledMask.lastIndexOf(path.sep) > 0) {
147
146
  mkdirPath = filledMask.substring(0, filledMask.lastIndexOf(path.sep));
148
147
  }
149
- const fileContent = opt.format !== 'xlsx' ? (converted + '\n') : converted;
148
+ const fileContent = (opt.format !== 'xlsx' && !converted.endsWith('\n')) ? (converted + '\n') : converted;
150
149
  if (!opt.version) {
151
150
  if (mkdirPath) mkdirp.sync(path.join(opt.path, version, mkdirPath));
152
151
  fs.writeFile(path.join(opt.path, version, filledMask), fileContent, clb);
@@ -233,7 +232,7 @@ function handlePull(opt, toDownload, cb) {
233
232
  }
234
233
 
235
234
  if (mkdirPath) mkdirp.sync(path.join(opt.path, mkdirPath));
236
- const fileContent = opt.format !== 'xlsx' ? (converted + '\n') : converted;
235
+ const fileContent = (opt.format !== 'xlsx' && !converted.endsWith('\n')) ? (converted + '\n') : converted;
237
236
  fs.writeFile(path.join(opt.path, filledMask), fileContent, logAndClb);
238
237
  } catch (e) {
239
238
  err.message = 'Invalid content for "' + opt.format + '" format!\n' + (err.message || '');
@@ -277,7 +276,7 @@ function handlePull(opt, toDownload, cb) {
277
276
  if (filledMask.lastIndexOf(path.sep) > 0) {
278
277
  mkdirPath = filledMask.substring(0, filledMask.lastIndexOf(path.sep));
279
278
  }
280
- const fileContent = opt.format !== 'xlsx' ? (converted + '\n') : converted;
279
+ const fileContent = (opt.format !== 'xlsx' && !converted.endsWith('\n')) ? (converted + '\n') : converted;
281
280
  if (!opt.language) {
282
281
  if (mkdirPath) mkdirp.sync(path.join(opt.path, mkdirPath));
283
282
  fs.writeFile(path.join(opt.path, filledMask), fileContent, clb);
package/format.js CHANGED
@@ -113,7 +113,7 @@ function writeLocalFile(opt, file, clb) {
113
113
  return clb(null, true);
114
114
  }
115
115
 
116
- const fileContent = opt.format !== 'xlsx' ? (file.converted + '\n') : file.converted;
116
+ const fileContent = (opt.format !== 'xlsx' && !file.converted.endsWith('\n')) ? (file.converted + '\n') : file.converted;
117
117
 
118
118
  fs.writeFile(file.path, fileContent, (err) => clb(err, true));
119
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "9.0.0",
3
+ "version": "9.0.2",
4
4
  "description": "locize cli to import locales",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -15,7 +15,7 @@
15
15
  "commander": "9.5.0",
16
16
  "csvjson": "5.1.0",
17
17
  "diff": "7.0.0",
18
- "dotenv": "16.4.7",
18
+ "dotenv": "16.5.0",
19
19
  "flat": "5.0.2",
20
20
  "fluent_conv": "3.3.0",
21
21
  "gettext-converter": "1.3.0",
@@ -23,7 +23,7 @@
23
23
  "ini": "4.1.3",
24
24
  "js-yaml": "4.1.0",
25
25
  "laravelphp": "2.0.4",
26
- "locize-xcstrings": "1.0.0",
26
+ "locize-xcstrings": "2.0.0",
27
27
  "lodash.clonedeep": "4.5.0",
28
28
  "mkdirp": "3.0.1",
29
29
  "node-fetch": "2.7.0",
@@ -31,11 +31,11 @@
31
31
  "rimraf": "4.4.1",
32
32
  "strings-file": "0.0.5",
33
33
  "tmexchange": "2.0.5",
34
- "xliff": "6.2.1",
34
+ "xliff": "6.2.2",
35
35
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
36
36
  },
37
37
  "devDependencies": {
38
- "@yao-pkg/pkg": "6.3.1",
38
+ "@yao-pkg/pkg": "6.4.0",
39
39
  "eslint": "8.56.0",
40
40
  "gh-release": "7.0.2"
41
41
  },
@@ -141,7 +141,7 @@ const parseLocalLanguage = (opt, lng, cb) => {
141
141
 
142
142
  if (opt.format === 'xcstrings') { // 1 file per namespace including all languages
143
143
  try {
144
- const content = xcstrings2locize(JSON.parse(data));
144
+ const content = xcstrings2locize(data);
145
145
 
146
146
  fs.stat(fPath, (err, stat) => {
147
147
  if (err) return clb(err);
package/sync.js CHANGED
@@ -258,8 +258,7 @@ const downloadAll = (opt, remoteLanguages, omitRef, manipulate, cb) => {
258
258
  if (err) return clb(err);
259
259
 
260
260
  try {
261
- const result = locize2xcstrings(locizeData);
262
- const converted = JSON.stringify(result, null, 2);
261
+ const converted = locize2xcstrings(locizeData);
263
262
 
264
263
  const filledMask = opt.pathMask.replace(`${opt.pathMaskInterpolationPrefix}language${opt.pathMaskInterpolationSuffix}`, '').replace(`${opt.pathMaskInterpolationPrefix}namespace${opt.pathMaskInterpolationSuffix}`, namespace) + reversedFileExtensionsMap[opt.format];
265
264
  if (opt.dry) return clb(null);
@@ -268,7 +267,7 @@ const downloadAll = (opt, remoteLanguages, omitRef, manipulate, cb) => {
268
267
  }
269
268
  const parentDir = path.dirname(path.join(opt.path, filledMask));
270
269
  mkdirp.sync(parentDir);
271
- const fileContent = opt.format !== 'xlsx' ? (converted + '\n') : converted;
270
+ const fileContent = (opt.format !== 'xlsx' && !converted.endsWith('\n')) ? (converted + '\n') : converted;
272
271
  fs.writeFile(path.join(opt.path, filledMask), fileContent, clb);
273
272
  } catch (e) {
274
273
  err.message = 'Invalid content for "' + opt.format + '" format!\n' + (err.message || '');
@@ -308,7 +307,7 @@ const downloadAll = (opt, remoteLanguages, omitRef, manipulate, cb) => {
308
307
  }
309
308
  const parentDir = path.dirname(path.join(opt.path, filledMask));
310
309
  mkdirp.sync(parentDir);
311
- const fileContent = opt.format !== 'xlsx' ? (converted + '\n') : converted;
310
+ const fileContent = (opt.format !== 'xlsx' && !converted.endsWith('\n')) ? (converted + '\n') : converted;
312
311
  fs.writeFile(path.join(opt.path, filledMask), fileContent, clb);
313
312
  });
314
313
  });
@@ -336,7 +335,7 @@ const update = (opt, lng, ns, shouldOmit, cb) => {
336
335
 
337
336
  function send(d, so, clb, isRetrying) {
338
337
  const queryParams = new URLSearchParams();
339
- if (opt.autoTranslate) {
338
+ if (opt.autoTranslate && lng === opt.referenceLanguage) {
340
339
  /** @See https://www.locize.com/docs/api#optional-autotranslate */
341
340
  queryParams.append('autotranslate', 'true');
342
341
  }
@@ -490,7 +489,7 @@ const backupDeleted = (opt, ns, now) => {
490
489
  }, {});
491
490
  mkdirp.sync(path.join(currentBackupPath, ns.language));
492
491
  const content = JSON.stringify(removingRemote, null, 2);
493
- const fileContent = opt.format !== 'xlsx' ? (content + '\n') : content;
492
+ const fileContent = (opt.format !== 'xlsx' && !content.endsWith('\n')) ? (content + '\n') : content;
494
493
  fs.writeFileSync(path.join(currentBackupPath, ns.language, `${ns.namespace}.json`), fileContent);
495
494
  };
496
495
 
@@ -666,6 +665,10 @@ const sync = (opt, cb) => {
666
665
  return handleError(new Error(`${opt.format} is not a valid format!`), cb);
667
666
  }
668
667
 
668
+ if (opt.autoTranslate && !opt.referenceLanguageOnly) {
669
+ console.log(colors.yellow('Using the "--auto-translate true" option together with the "--reference-language-only false" option might result in inconsistent target language translations (automatic translation vs. what is sent direcly to locize).'));
670
+ }
671
+
669
672
  opt.version = opt.version || 'latest';
670
673
  opt.apiPath = opt.apiPath || 'https://api.locize.app';
671
674