@kununu/phraseapp-cli 4.0.0-beta.0 → 4.0.0-beta.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/check-translations.js +5 -13
- package/package.json +1 -1
package/check-translations.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
//import { readFileSync, writeFileSync, unlinkSync, existsSync } from 'fs';
|
|
2
|
-
//import { sync } from 'glob';
|
|
3
|
-
//import { parse } from '@babel/parser';
|
|
4
|
-
//import traverse from '@babel/traverse';
|
|
5
|
-
|
|
6
1
|
const { readFileSync, writeFileSync, unlinkSync, existsSync } = require('fs');
|
|
7
2
|
const {sync} = require('glob');
|
|
8
3
|
const {parse} = require('@babel/parser');
|
|
9
4
|
const traverse = require('@babel/traverse');
|
|
10
5
|
|
|
11
|
-
|
|
12
|
-
// const TRANSLATIONS_FILE = `${process.cwd()}/translations/de_AT.json`;
|
|
13
|
-
const DYNAMIC_KEYS_FILE = `${process.cwd()}/dynamic_keys.json`;
|
|
14
6
|
const UNUSED_KEYS_FILE = 'not_used_keys.json';
|
|
15
7
|
const MISSING_KEYS_FILE = 'missing_keys.json';
|
|
16
8
|
const POSSIBLE_DYNAMIC_KEYS_FILE = 'possible_dynamic_keys.json';
|
|
17
9
|
|
|
18
10
|
function extractTranslationKeys() {
|
|
19
|
-
const files = sync(`${process.env.SOURCE_DIR}/**/**/*.{js,jsx,ts,tsx}`);
|
|
11
|
+
const files = sync(`${process.cwd()}/${process.env.SOURCE_DIR}/**/**/*.{js,jsx,ts,tsx}`);
|
|
20
12
|
const keys = new Set();
|
|
21
13
|
const possibleDynamicKeys = {};
|
|
22
14
|
|
|
@@ -70,9 +62,9 @@ function compareKeys() {
|
|
|
70
62
|
const appKeys = extractTranslationKeys();
|
|
71
63
|
|
|
72
64
|
try {
|
|
73
|
-
const phrase = JSON.parse(
|
|
65
|
+
const phrase = JSON.parse(readFileSync(configPath));
|
|
74
66
|
const translations = JSON.parse(readFileSync(`${phrase.path}/de_AT.json`, 'utf8'));
|
|
75
|
-
const dynamicKeys =
|
|
67
|
+
const dynamicKeys = phrase.dynamicKeys || [];
|
|
76
68
|
|
|
77
69
|
const allValidKeys = new Set(Object.keys(translations));
|
|
78
70
|
|
|
@@ -108,8 +100,8 @@ function compareKeys() {
|
|
|
108
100
|
console.log(`${UNUSED_KEYS_FILE} was deleted as there are no missing keys.`);
|
|
109
101
|
}
|
|
110
102
|
} catch (error) {
|
|
111
|
-
console.error(
|
|
103
|
+
console.error(error);
|
|
112
104
|
}
|
|
113
105
|
}
|
|
114
106
|
|
|
115
|
-
compareKeys();
|
|
107
|
+
compareKeys();
|