Files
web/scripts/i18n/clean.mjs
Anton Gunnarsson 233c685e52 Merged in feat/sw-2333-package-and-sas-i18n (pull request #2538)
feat(SW-2333): I18n for multiple apps and packages

* Set upp i18n in partner-sas

* Adapt lokalise workflow to monorepo

* Fix layout props


Approved-by: Linus Flood
2025-07-10 07:00:03 +00:00

56 lines
1.2 KiB
JavaScript

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()