locize-cli 7.9.1 → 7.11.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 CHANGED
@@ -5,6 +5,19 @@ 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
+ ## [7.11.0](https://github.com/locize/locize-cli/compare/v7.10.1...v7.11.0) - 2022-06-13
9
+
10
+ - alpine build
11
+ - update dependencies
12
+
13
+ ## [7.10.1](https://github.com/locize/locize-cli/compare/v7.10.0...v7.10.1) - 2022-04-07
14
+
15
+ - cache dns lookups
16
+
17
+ ## [7.10.0](https://github.com/locize/locize-cli/compare/v7.9.1...v7.10.0) - 2022-03-15
18
+
19
+ - gettext_i18next: try to detect v4 format
20
+
8
21
  ## [7.9.1](https://github.com/locize/locize-cli/compare/v7.9.0...v7.9.1) - 2022-03-02
9
22
 
10
23
  - xliff: fix combined plural keys
@@ -56,11 +56,13 @@ const convertToDesiredFormat = (
56
56
  }
57
57
  if (opt.format === 'po_i18next' || opt.format === 'gettext_i18next') {
58
58
  const flatData = flatten(data);
59
+ const compatibilityJSON = !!Object.keys(flatData).find((k) => /_(zero|one|two|few|many|other)/.test(k)) && 'v4';
59
60
  const gettextOpt = {
60
61
  project: 'locize',
61
62
  language: lng,
62
63
  potCreationDate: lastModified,
63
- poRevisionDate: lastModified
64
+ poRevisionDate: lastModified,
65
+ compatibilityJSON
64
66
  };
65
67
  cb(null, i18next2po(lng, flatData, gettextOpt));
66
68
  return;
@@ -40,7 +40,9 @@ const convertToFlatFormat = (opt, data, lng, cb) => {
40
40
  }
41
41
  if (opt.format === 'po_i18next' || opt.format === 'gettext_i18next') {
42
42
  try {
43
- const ret = po2i18next(data.toString());
43
+ const potxt = data.toString();
44
+ const compatibilityJSON = /msgctxt "(zero|one|two|few|many|other)"/.test(potxt) && 'v4';
45
+ const ret = po2i18next(potxt, { compatibilityJSON });
44
46
  cb(null, flatten(ret));
45
47
  } catch (err) {
46
48
  cb(err);
package/format.js CHANGED
@@ -150,7 +150,7 @@ function processFiles(opt, filePaths, clb) {
150
150
  files.forEach((f) => {
151
151
  if (f.content) {
152
152
  Object.keys(f.content).forEach((k) => {
153
- if (f.content[k] && typeof f.content[k] === 'object' && typeof f.content[k].value !== undefined) {
153
+ if (f.content[k] && typeof f.content[k] === 'object' && f.content[k].value !== undefined) {
154
154
  f.content[k] = f.content[k].value;
155
155
  }
156
156
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "7.9.1",
3
+ "version": "7.11.0",
4
4
  "description": "locize cli to import locales",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -9,16 +9,17 @@
9
9
  "dependencies": {
10
10
  "@js.properties/properties": "0.5.4",
11
11
  "android-string-resource": "2.3.4",
12
- "async": "3.2.3",
12
+ "async": "3.2.4",
13
+ "cacheable-lookup": "6.0.4",
13
14
  "colors": "1.4.0",
14
- "commander": "9.0.0",
15
+ "commander": "9.3.0",
15
16
  "csvjson": "5.1.0",
16
- "diff": "5.0.0",
17
+ "diff": "5.1.0",
17
18
  "flat": "5.0.2",
18
19
  "fluent_conv": "3.1.0",
19
- "gettext-converter": "1.2.0",
20
- "https-proxy-agent": "5.0.0",
21
- "ini": "2.0.0",
20
+ "gettext-converter": "1.2.2",
21
+ "https-proxy-agent": "5.0.1",
22
+ "ini": "3.0.0",
22
23
  "js-yaml": "4.1.0",
23
24
  "laravelphp": "2.0.3",
24
25
  "lodash.clonedeep": "4.5.0",
@@ -29,18 +30,18 @@
29
30
  "strings-file": "0.0.5",
30
31
  "tmexchange": "2.0.4",
31
32
  "xliff": "6.0.3",
32
- "xlsx": "0.18.2"
33
+ "xlsx": "0.18.5"
33
34
  },
34
35
  "devDependencies": {
35
- "eslint": "7.32.0",
36
- "gh-release": "6.0.1",
37
- "pkg": "5.5.2"
36
+ "eslint": "8.17.0",
37
+ "gh-release": "6.0.4",
38
+ "pkg": "5.7.0"
38
39
  },
39
40
  "scripts": {
40
41
  "lint": "eslint .",
41
42
  "test": "npm run lint",
42
- "pkg": "mkdir -p ./bins && pkg ./bin/locize --out-path ./bins --targets node16-linux-x64,node16-macos-x64,node16-win-x64",
43
- "release": "gh-release --assets ./bins/locize-linux,./bins/locize-macos,./bins/locize-win.exe",
43
+ "pkg": "mkdir -p ./bins && pkg ./bin/locize --out-path ./bins --targets node16-linux-x64,node16-macos-x64,node16-win-x64,node16-alpine-x64",
44
+ "release": "gh-release --assets ./bins/locize-linux,./bins/locize-macos,./bins/locize-win.exe,./bins/locize-alpine",
44
45
  "version": "npm run pkg",
45
46
  "postversion": "git push && npm run release"
46
47
  },
package/request.js CHANGED
@@ -1,10 +1,19 @@
1
1
  const package = require('./package.json');
2
2
  const fetch = require('node-fetch');
3
3
  const HttpsProxyAgent = require('https-proxy-agent');
4
+ const https = require('https');
5
+ const CacheableLookup = require('cacheable-lookup');
6
+ const cacheable = new CacheableLookup();
7
+ cacheable.install(https.globalAgent);
8
+
4
9
  const httpProxy = process.env.http_proxy || process.env.HTTP_PROXY || process.env.https_proxy || process.env.HTTPS_PROXY;
5
10
 
6
11
  module.exports = (url, options, callback) => {
7
- if (httpProxy) options.agent = new HttpsProxyAgent(httpProxy);
12
+ if (httpProxy) {
13
+ const httpsProxyAgent = new HttpsProxyAgent(httpProxy);
14
+ cacheable.install(httpsProxyAgent);
15
+ options.agent = httpsProxyAgent;
16
+ }
8
17
 
9
18
  options.headers = options.headers || {};
10
19
  options.headers['User-Agent'] = `${package.name}/v${package.version} (node/${process.version}; ${process.platform} ${process.arch})`;
@@ -23,7 +32,11 @@ module.exports = (url, options, callback) => {
23
32
  return { res };
24
33
  }
25
34
  }).then((ret) => callback(null, ret.res, ret.obj)).catch((err) => {
26
- if (err && err.message && err.message.indexOf('ENOTFOUND') > -1) {
35
+ if (err && err.message && (
36
+ err.message.indexOf('ENOTFOUND') > -1 ||
37
+ err.message.indexOf('ENODATA') > -1 ||
38
+ err.message.indexOf('ENOENT') > -1 // Windows: name exists, but not this record type
39
+ )) {
27
40
  setTimeout(() => {
28
41
  fetch(url, options).then((res) => {
29
42
  if (res.headers.get('content-type') && res.headers.get('content-type').indexOf('json') > 0) {
@@ -32,7 +45,7 @@ module.exports = (url, options, callback) => {
32
45
  return { res };
33
46
  }
34
47
  }).then((ret) => callback(null, ret.res, ret.obj)).catch(callback);
35
- }, 3000);
48
+ }, 5000);
36
49
  return;
37
50
  }
38
51
  callback(err);