Skip to content

Commit ce8186d

Browse files
committed
Remove translations help function
Signed-off-by: Geoff Wilson <[email protected]>
1 parent 6f7cace commit ce8186d

File tree

1 file changed

+0
-38
lines changed

1 file changed

+0
-38
lines changed

scripts/find-missing-translations.js

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
* --locale=<locale> Only check a specific locale (e.g. --locale=fr)
99
* --file=<file> Only check a specific file (e.g. --file=chat.json)
1010
* --area=<area> Only check a specific area (core, webview, or both)
11-
* --create-missing Creates missing keys in the other locales with the EN value
1211
* --help Show this help message
1312
*/
1413

15-
const { set } = require("@dotenvx/dotenvx")
1614
const fs = require("fs")
1715
const path = require("path")
18-
let createMissing = false
1916

2017
// Process command line arguments
2118
const args = process.argv.slice(2).reduce(
@@ -33,8 +30,6 @@ const args = process.argv.slice(2).reduce(
3330
console.error(`Error: Invalid area '${acc.area}'. Must be 'core', 'webview', or 'both'.`)
3431
process.exit(1)
3532
}
36-
} else if (arg.startsWith("--create-missing")) {
37-
createMissing = true
3833
}
3934
return acc
4035
},
@@ -59,7 +54,6 @@ Options:
5954
'core' = Backend (src/i18n/locales)
6055
'webview' = Frontend UI (webview-ui/src/i18n/locales)
6156
'both' = Check both areas (default)
62-
--create-missing Creates missing keys in the other locales with the EN value
6357
--help Show this help message
6458
6559
Output:
@@ -111,32 +105,6 @@ function getValueAtPath(obj, path) {
111105
return current
112106
}
113107

114-
// Set value at a dotted path in an object
115-
function setValueAtPath(obj, path, value) {
116-
const parts = path.split(".")
117-
let current = obj
118-
119-
for (let i = 0; i < parts.length; i++) {
120-
const part = parts[i]
121-
122-
// Guard against prototype pollution
123-
if (part === "__proto__" || part === "constructor" || part === "prototype") {
124-
continue
125-
}
126-
127-
// If it's the last part, set the value
128-
if (i === parts.length - 1) {
129-
current[part] = value
130-
} else {
131-
// If the key doesn't exist or isn't an object, create an empty object
132-
if (current[part] === undefined || typeof current[part] !== "object") {
133-
current[part] = {}
134-
}
135-
current = current[part]
136-
}
137-
}
138-
}
139-
140108
// Function to check translations for a specific area
141109
function checkAreaTranslations(area) {
142110
const LOCALES_DIR = LOCALES_DIRS[area]
@@ -230,17 +198,11 @@ function checkAreaTranslations(area) {
230198
key,
231199
englishValue,
232200
})
233-
if (createMissing === true) {
234-
setValueAtPath(localeContent, key, englishValue) // Set the missing key in the locale content
235-
}
236201
}
237202
}
238203

239204
if (missingKeys.length > 0) {
240205
missingTranslations[locale][name] = missingKeys
241-
if (createMissing === true) {
242-
fs.writeFileSync(localeFilePath, JSON.stringify(localeContent, null, "\t"))
243-
}
244206
}
245207
}
246208
}

0 commit comments

Comments
 (0)