forked from codecombat/codecombat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-long-i18n.js
34 lines (31 loc) · 927 Bytes
/
check-long-i18n.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const en = require('../app/locale/en.js').translation
const locale = require('../app/locale/locale')
function checkLang (lang) {
if (lang === 'en') {
return
}
const language = require(`../app/locale/${lang}.js`).translation
Object.keys(en).forEach(key => {
if (!language[key]) {
// console.log(`Missing key: ${key}`)
return
}
Object.keys(en[key]).forEach(subKey => {
if (!language[key][subKey]) {
// console.log(`Missing key: ${key}.${subKey}`)
return
}
const enLength = en[key][subKey].length
const langLength = language[key][subKey].replace('[AI_TRANSLATION]', '').length
if (langLength - enLength > 20 && langLength > enLength * 2) {
console.log(`${lang} Too long: ${key}.${subKey} - ${langLength} vs ${enLength}`)
}
})
})
}
function main () {
Object.keys(locale).forEach(lang => {
checkLang(lang)
})
}
main()