-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfind_direct.js
More file actions
49 lines (41 loc) · 1.71 KB
/
find_direct.js
File metadata and controls
49 lines (41 loc) · 1.71 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const toml = require('toml');
const fs = require('fs');
const content = fs.readFileSync('./locales/docs/typst-docs.toml', 'utf8');
const data = toml.parse(content);
function findDirectTranslations(obj, path = '') {
let directTranslations = [];
for (const [key, value] of Object.entries(obj)) {
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
if ('en' in value && !('zh' in value)) {
// Check if it's a direct translation (not a file reference)
if (!value.en.includes('{{typst-docs/')) {
directTranslations.push({
path: path + key,
en: value.en.length > 100 ? value.en.substring(0, 100) + '...' : value.en
});
}
} else if (!('en' in value)) {
directTranslations = directTranslations.concat(findDirectTranslations(value, path + key + '.'));
}
}
}
return directTranslations;
}
const directTranslations = findDirectTranslations(data);
console.log('Found', directTranslations.length, 'entries needing direct translation (not file references)');
// Focus on foundation types first
const foundationDirect = directTranslations.filter(item =>
item.path.startsWith('reference.foundations')
);
console.log('\nFoundation types needing direct translation (first 50):');
foundationDirect.slice(0, 50).forEach((item, i) => {
console.log((i+1) + '. ' + item.path);
console.log(' EN: ' + item.en);
console.log('');
});
console.log('\nOther entries needing direct translation (first 30):');
directTranslations.filter(item => !item.path.startsWith('reference.foundations')).slice(0, 30).forEach((item, i) => {
console.log((i+1) + '. ' + item.path);
console.log(' EN: ' + item.en);
console.log('');
});