mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
0b7e28432d
[web] scripts: add script for checking coverage of non-en translations GitOrigin-RevId: ccde0d5b56b9e3b8f2a32916ecf1b442482edd12
35 lines
817 B
JavaScript
35 lines
817 B
JavaScript
const fs = require('fs')
|
|
const Path = require('path')
|
|
|
|
const LOCALES = Path.join(__dirname, '../../locales')
|
|
const SORT_BY_PROGRESS = process.argv.includes('--sort-by-progress')
|
|
|
|
function count(file) {
|
|
return Object.keys(require(Path.join(LOCALES, file))).length
|
|
}
|
|
|
|
async function main() {
|
|
const EN = count('en.json')
|
|
const rows = []
|
|
|
|
for (const file of await fs.promises.readdir(LOCALES)) {
|
|
if (file === 'README.md') continue
|
|
const n = count(file)
|
|
const name = file.replace('.json', '')
|
|
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)
|
|
}
|
|
|
|
main().catch(error => {
|
|
console.error(error)
|
|
process.exit(1)
|
|
})
|