mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-08-19 09:08:25 +02:00
vibe code some more script functionality
This commit is contained in:
parent
8579f20d64
commit
7b0b0e931c
1 changed files with 36 additions and 4 deletions
|
@ -218,8 +218,7 @@ function checkStatus(locale) {
|
||||||
|
|
||||||
const overallPercentage = totalTotal > 0 ? ((totalPresent / totalTotal) * 100).toFixed(2) : "0.00";
|
const overallPercentage = totalTotal > 0 ? ((totalPresent / totalTotal) * 100).toFixed(2) : "0.00";
|
||||||
|
|
||||||
console.log(`
|
console.log(`\n--- Status for ${locale} ---\n`);
|
||||||
--- Status for ${locale} ---`);
|
|
||||||
console.log(`Overall Completion: ${overallPercentage}% (${totalPresent}/${totalTotal})`);
|
console.log(`Overall Completion: ${overallPercentage}% (${totalPresent}/${totalTotal})`);
|
||||||
|
|
||||||
const levelPercentage = levelStatus.total > 0 ? ((levelStatus.present / levelStatus.total) * 100).toFixed(2) : "0.00";
|
const levelPercentage = levelStatus.total > 0 ? ((levelStatus.present / levelStatus.total) * 100).toFixed(2) : "0.00";
|
||||||
|
@ -240,6 +239,37 @@ function checkStatus(locale) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalize() {
|
||||||
|
console.log('Normalizing all level and string files...');
|
||||||
|
|
||||||
|
// Normalize levels
|
||||||
|
const levelsDir = path.join(__dirname, '../src/levels');
|
||||||
|
const levelFiles = getAllLevelFiles(levelsDir);
|
||||||
|
for (const file of levelFiles) {
|
||||||
|
const levelPath = file;
|
||||||
|
delete require.cache[require.resolve(levelPath)];
|
||||||
|
const levelData = require(levelPath);
|
||||||
|
if (levelData && levelData.level) {
|
||||||
|
const newContent = `exports.level = ${JSON.stringify(levelData.level, null, 2)};`;
|
||||||
|
fs.writeFileSync(levelPath, newContent, 'utf8');
|
||||||
|
console.log(`Normalized ${file}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize strings
|
||||||
|
const stringsPath = path.join(__dirname, '../src/js/intl/strings.js');
|
||||||
|
delete require.cache[require.resolve(stringsPath)];
|
||||||
|
const stringsData = require(stringsPath);
|
||||||
|
if (stringsData && stringsData.strings) {
|
||||||
|
const newContent = `exports.strings = ${JSON.stringify(stringsData.strings, null, 2)};`;
|
||||||
|
fs.writeFileSync(stringsPath, newContent, 'utf8');
|
||||||
|
console.log(`Normalized ${stringsPath}`);
|
||||||
|
console.log('NOTE: Comments and original formatting in strings.js have been removed by this process.');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('\nNormalization complete.');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const arg = process.argv[2];
|
const arg = process.argv[2];
|
||||||
const nextArg = process.argv[3];
|
const nextArg = process.argv[3];
|
||||||
|
@ -252,6 +282,7 @@ async function main() {
|
||||||
console.error(' node scripts/translate.js --status <locale>');
|
console.error(' node scripts/translate.js --status <locale>');
|
||||||
console.error(' node scripts/translate.js --translate-levels <locale>');
|
console.error(' node scripts/translate.js --translate-levels <locale>');
|
||||||
console.error(' node scripts/translate.js --translate-strings <locale>');
|
console.error(' node scripts/translate.js --translate-strings <locale>');
|
||||||
|
console.error(' node scripts/translate.js --normalize');
|
||||||
console.error(' node scripts/translate.js <locale> (Translates all missing strings for a locale)');
|
console.error(' node scripts/translate.js <locale> (Translates all missing strings for a locale)');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
@ -276,12 +307,13 @@ async function main() {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
await translateStrings(nextArg);
|
await translateStrings(nextArg);
|
||||||
|
} else if (arg === '--normalize') {
|
||||||
|
normalize();
|
||||||
} else {
|
} else {
|
||||||
console.log(`Translating all missing strings for ${arg}...`);
|
console.log(`Translating all missing strings for ${arg}...`);
|
||||||
await translateLevels(arg);
|
await translateLevels(arg);
|
||||||
await translateStrings(arg);
|
await translateStrings(arg);
|
||||||
console.log(`
|
console.log(`\nFinished translating all missing strings for ${arg}.`);
|
||||||
Finished translating all missing strings for ${arg}.`);
|
|
||||||
checkStatus(arg);
|
checkStatus(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue