ci: replacing 100% and 100.00% with for translation progress in README.md

This commit is contained in:
leo 2025-01-22 11:19:48 +08:00
parent 6ae66095c2
commit 75288e7a31
No known key found for this signature in database

View file

@ -25,7 +25,7 @@ async function calculateTranslationRate() {
const files = (await fs.readdir(localesDir)).filter(file => file !== 'en_US.axaml' && file.endsWith('.axaml')); const files = (await fs.readdir(localesDir)).filter(file => file !== 'en_US.axaml' && file.endsWith('.axaml'));
// Add en_US badge first // Add en_US badge first
badges.push(`[![en_US](https://img.shields.io/badge/en__US-100%25-brightgreen)](TRANSLATION.md)`); badges.push(`[![en_US](https://img.shields.io/badge/en_US-%E2%88%9A-brightgreen)](TRANSLATION.md)`);
for (const file of files) { for (const file of files) {
const filePath = path.join(localesDir, file); const filePath = path.join(localesDir, file);
@ -40,9 +40,13 @@ async function calculateTranslationRate() {
// Add badges // Add badges
const locale = file.replace('.axaml', '').replace('_', '__'); const locale = file.replace('.axaml', '').replace('_', '__');
const badgeColor = translationRate === 100 ? 'brightgreen' : translationRate >= 75 ? 'yellow' : 'red'; if (translationRate === 100) {
badges.push(`[![${locale}](https://img.shields.io/badge/${locale}-%E2%88%9A-brightgreen)](TRANSLATION.md)`);
} else {
const badgeColor = translationRate >= 75 ? 'yellow' : 'red';
badges.push(`[![${locale}](https://img.shields.io/badge/${locale}-${translationRate.toFixed(2)}%25-${badgeColor})](TRANSLATION.md)`); badges.push(`[![${locale}](https://img.shields.io/badge/${locale}-${translationRate.toFixed(2)}%25-${badgeColor})](TRANSLATION.md)`);
} }
}
console.log(translationRates.join('\n\n')); console.log(translationRates.join('\n\n'));