2024-10-24 08:18:37 -04:00
|
|
|
import fs from 'fs'
|
|
|
|
import Path from 'path'
|
|
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
import { loadLocale } from './utils.js'
|
2023-01-12 04:51:42 -05:00
|
|
|
|
2024-10-24 08:18:37 -04:00
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
2023-01-12 04:51:42 -05:00
|
|
|
const LOCALES = Path.join(__dirname, '../../locales')
|
|
|
|
const SORT_BY_PROGRESS = process.argv.includes('--sort-by-progress')
|
|
|
|
|
2024-10-24 08:18:37 -04:00
|
|
|
function count(language) {
|
|
|
|
const locale = loadLocale(language)
|
|
|
|
return Object.keys(locale).length
|
2023-01-12 04:51:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
async function main() {
|
2024-10-24 08:18:37 -04:00
|
|
|
const EN = count('en')
|
2023-01-12 04:51:42 -05:00
|
|
|
const rows = []
|
|
|
|
|
|
|
|
for (const file of await fs.promises.readdir(LOCALES)) {
|
|
|
|
if (file === 'README.md') continue
|
|
|
|
const name = file.replace('.json', '')
|
2024-10-24 08:18:37 -04:00
|
|
|
const n = count(name)
|
2023-01-12 04:51:42 -05:00
|
|
|
rows.push({
|
|
|
|
name,
|
|
|
|
done: n,
|
|
|
|
missing: EN - n,
|
|
|
|
progress: ((100 * n) / EN).toFixed(2).padStart(5, ' ') + '%',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (SORT_BY_PROGRESS) {
|
|
|
|
rows.sort((a, b) => b.done - a.done)
|
|
|
|
}
|
|
|
|
console.table(rows)
|
|
|
|
}
|
|
|
|
|
2024-10-24 08:18:37 -04:00
|
|
|
try {
|
|
|
|
await main()
|
|
|
|
} catch (error) {
|
2023-01-12 04:51:42 -05:00
|
|
|
console.error(error)
|
|
|
|
process.exit(1)
|
2024-10-24 08:18:37 -04:00
|
|
|
}
|