Translate finished messages by template and the world clock, Dropbox and scoped titles at display
This commit is contained in:
1 parent
2b2302a279
commit
f63ecb6697
13 files changed
+139
-28
No files matched your search
@@ -10,7 +10,7 @@ const vm = require('vm')
|
||||
|
||||
const source = fs.readFileSync(path.join(root, 'shell/Commons/I18nZh.js'), 'utf8').replace('.pragma library', '')
|
||||
const context = {}
|
||||
vm.runInNewContext(source + '\nthis.table = table', context)
|
||||
vm.runInNewContext(source + '\nthis.table = table; this.templates = templates', context)
|
||||
const table = context.table
|
||||
|
||||
const files = []
|
||||
@@ -27,6 +27,12 @@ const missing = []
|
||||
let calls = 0
|
||||
for (const file of files) {
|
||||
const text = fs.readFileSync(file, 'utf8')
|
||||
for (const list of text.matchAll(/I18n\.trMatch\([^\[]*\[([^\]]*)\]/g)) {
|
||||
for (const item of list[1].matchAll(/"((?:[^"\\]|\\.)*)"/g)) {
|
||||
const key = JSON.parse('"' + item[1] + '"')
|
||||
if (!(key in table)) missing.push(`${path.relative(root, file)}: ${key}`)
|
||||
}
|
||||
}
|
||||
for (const match of text.matchAll(/I18n\.tr\(\s*"((?:[^"\\]|\\.)*)"/g)) {
|
||||
calls++
|
||||
const key = JSON.parse('"' + match[1] + '"')
|
||||
@@ -34,6 +40,8 @@ for (const file of files) {
|
||||
}
|
||||
}
|
||||
assert(calls > 300, 'the shell routes its text through I18n.tr', `found ${calls} calls`)
|
||||
const missingTemplates = Array.from(context.templates).filter(t => !(t in table))
|
||||
assert(missingTemplates.length === 0, 'every message template has a Chinese entry', missingTemplates.join('\n'))
|
||||
assert(missing.length === 0, 'every I18n.tr text has a Chinese entry', missing.join('\n'))
|
||||
|
||||
const placeholders = s => (s.match(/%\d/g) || []).sort().join(',')
|
||||
|
||||
Reference in new issue
Block a user