auto-lang 1.1.0 → 1.1.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/package.json +1 -1
- package/src/index.js +5 -3
package/package.json
CHANGED
package/src/index.js
CHANGED
@@ -8,10 +8,12 @@ import translate from 'translate';
|
|
8
8
|
import JsonToTS from 'json-to-ts';
|
9
9
|
import prettier from 'prettier';
|
10
10
|
|
11
|
+
import pJson from '../package.json' assert { type: "json" };
|
11
12
|
import {Logger} from './utils/Logger.mjs';
|
12
13
|
import {validateOptions} from './utils/validation.mjs';
|
13
14
|
|
14
|
-
const
|
15
|
+
const {version: appVersion} = pJson;
|
16
|
+
|
15
17
|
|
16
18
|
const program = new Command();
|
17
19
|
const nodeMajVer = parseInt(process.version.substring(1).split('.')[0]);
|
@@ -25,7 +27,7 @@ if (nodeMajVer < 14) {
|
|
25
27
|
program
|
26
28
|
.name('auto-lang')
|
27
29
|
.description('Generate translation files for multiple languages (i18n)')
|
28
|
-
.version(
|
30
|
+
.version(appVersion)
|
29
31
|
.option('-f, --from <lang>', 'language to translate from')
|
30
32
|
.option(
|
31
33
|
'-t, --to <lang...>',
|
@@ -51,7 +53,7 @@ const inputJson = JSON.parse(
|
|
51
53
|
async function makeTranslatedCopy(obj1, obj2, options) {
|
52
54
|
for (let [key, value] of Object.entries(obj1)) {
|
53
55
|
if (typeof value === 'object') {
|
54
|
-
obj2[key] = {};
|
56
|
+
obj2[key] = obj2[key] || {};
|
55
57
|
await makeTranslatedCopy(value, obj2[key], options);
|
56
58
|
} else {
|
57
59
|
try {
|