feat: lokalise clean

This commit is contained in:
Michael Zetterberg
2025-06-10 12:44:44 +02:00
parent 4f75c4a60f
commit 2c9f3c4c5e
3 changed files with 109 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
import { stdin as input, stdout as output } from "node:process"
import * as readline from "node:readline/promises"
import { config } from "dotenv"
const rl = readline.createInterface({ input, output })
config({ path: `${process.cwd()}/.env.local` })
function diffArray(json1, json2) {
const diff = []
const keys1 = Object.keys(json1)
const keys2 = Object.keys(json2)
keys1.forEach((key) => {
if (!keys2.includes(key)) {
diff.push(key)
}
})
return diff
}
async function main() {
const answer = await rl.question(
"To make sure we use the latest data for the diff, have you run i18n:download AND i18n:extract BEFORE running this? Type yes or no "
)
if (answer !== "yes") {
console.log("")
console.warn(
"Please run i18n:download AND i18n:extract BEFORE running this."
)
rl.close()
process.exit(1)
}
rl.close()
const allLokalise = await import("./translations-all/en.json", {
with: {
type: "json",
},
})
const fromCodebase = await import("./extracted.json", {
with: {
type: "json",
},
})
const labelsToRemove = diffArray(allLokalise, fromCodebase)
const { deleteBulk } = await import("./lokalise")
await deleteBulk(labelsToRemove)
}
main()