adapt-authoring-lang 1.0.6 → 1.0.7
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/bin/check.js +18 -9
- package/package.json +1 -1
package/bin/check.js
CHANGED
|
@@ -14,13 +14,15 @@ const underline = (s = '', topLine = true) => {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async function check () {
|
|
17
|
-
|
|
17
|
+
underline('Language String Check')
|
|
18
18
|
|
|
19
19
|
const translatedStrings = await getTranslatedStrings()
|
|
20
|
+
console.log('\n Languages found:')
|
|
21
|
+
Object.keys(translatedStrings).forEach(l => console.log(' -', l))
|
|
20
22
|
|
|
21
23
|
for (const lang of Object.keys(translatedStrings)) {
|
|
22
|
-
console.log('\n
|
|
23
|
-
underline(`Language: ${lang}`.toUpperCase()
|
|
24
|
+
console.log('\n')
|
|
25
|
+
underline(`Language: ${lang}`.toUpperCase())
|
|
24
26
|
|
|
25
27
|
const langStrings = translatedStrings[lang]
|
|
26
28
|
const usedStrings = await getUsedStrings(langStrings)
|
|
@@ -28,11 +30,18 @@ async function check () {
|
|
|
28
30
|
const missingStrings = Object.entries(usedStrings).filter(([key]) => !langStrings[key] && !key.startsWith('error') && key !== 'app.js')
|
|
29
31
|
|
|
30
32
|
console.log()
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (unusedStrings.length) {
|
|
34
|
+
logStrings(unusedStrings, 'translated strings unreferenced in the code')
|
|
35
|
+
console.log()
|
|
36
|
+
}
|
|
37
|
+
if (missingStrings.length) {
|
|
38
|
+
logStrings(missingStrings, 'strings without translation')
|
|
39
|
+
console.log()
|
|
40
|
+
}
|
|
41
|
+
if (!unusedStrings.length && !missingStrings.length) {
|
|
42
|
+
console.log('✓ No issues found!\n')
|
|
43
|
+
}
|
|
44
|
+
underline(`Summary:\n - ${unusedStrings.length} unused language strings found\n - ${missingStrings.length} missing language strings found`)
|
|
36
45
|
}
|
|
37
46
|
console.log()
|
|
38
47
|
}
|
|
@@ -89,7 +98,7 @@ async function getUsedStrings (translatedStrings) {
|
|
|
89
98
|
|
|
90
99
|
function logStrings (strings, message) {
|
|
91
100
|
if (!strings.length) {
|
|
92
|
-
return
|
|
101
|
+
return console.log(`✓ No ${message}`)
|
|
93
102
|
}
|
|
94
103
|
underline(`Found ${strings.length} ${message}`)
|
|
95
104
|
console.log(`${strings.map(s => `\n- ${s}`).join('')}`)
|