Skip to content

Commit 39f4cd1

Browse files
committed
ci: move all translation status to TRANSLATION.md and do not modify README.md while checking localization
Signed-off-by: leo <[email protected]>
1 parent cdc0fbb commit 39f4cd1

File tree

3 files changed

+38
-80
lines changed

3 files changed

+38
-80
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Supports SSH access with each remote
1919
* GIT commands with GUI
2020
* Clone/Fetch/Pull/Push...
21-
* Merge/Rebase/Reset/Revert/Amend/Cherry-pick...
21+
* Merge/Rebase/Reset/Revert/Cherry-pick...
2222
* Amend/Reword/Squash
2323
* Interactive rebase
2424
* Branches
@@ -48,10 +48,7 @@
4848
4949
## Translation Status
5050

51-
[![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-98.92%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-99.87%25-yellow)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-%E2%88%9A-brightgreen)](TRANSLATION.md) [![it__IT](https://img.shields.io/badge/it__IT-99.87%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-91.12%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-%E2%88%9A-brightgreen)](TRANSLATION.md)
52-
53-
> [!NOTE]
54-
> You can find the missing keys in [TRANSLATION.md](TRANSLATION.md)
51+
You can find the current translation status in [TRANSLATION.md](TRANSLATION.md)
5552

5653
## How to Use
5754

TRANSLATION.md

Lines changed: 19 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
### de_DE.axaml: 98.92%
1+
# Translation Status
22

3+
This document shows the translation status of each locale file in the repository.
4+
5+
## Details
6+
7+
### ![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen)
8+
9+
### ![de__DE](https://img.shields.io/badge/de__DE-98.92%25-yellow)
310

411
<details>
5-
<summary>Missing Keys</summary>
12+
<summary>Missing keys in de_DE.axaml</summary>
613

714
- Text.BranchUpstreamInvalid
815
- Text.Configure.CustomAction.WaitForExit
@@ -15,41 +22,30 @@
1522

1623
</details>
1724

18-
### es_ES.axaml: 99.87%
19-
25+
### ![es__ES](https://img.shields.io/badge/es__ES-99.87%25-yellow)
2026

2127
<details>
22-
<summary>Missing Keys</summary>
28+
<summary>Missing keys in es_ES.axaml</summary>
2329

2430
- Text.Preferences.General.ShowTagsInGraph
2531

2632
</details>
2733

28-
### fr_FR.axaml: 100.00%
34+
### ![fr__FR](https://img.shields.io/badge/fr__FR-%E2%88%9A-brightgreen)
2935

36+
### ![it__IT](https://img.shields.io/badge/it__IT-99.87%25-yellow)
3037

3138
<details>
32-
<summary>Missing Keys</summary>
33-
34-
35-
36-
</details>
37-
38-
### it_IT.axaml: 99.87%
39-
40-
41-
<details>
42-
<summary>Missing Keys</summary>
39+
<summary>Missing keys in it_IT.axaml</summary>
4340

4441
- Text.Preferences.General.ShowTagsInGraph
4542

4643
</details>
4744

48-
### pt_BR.axaml: 91.12%
49-
45+
### ![pt__BR](https://img.shields.io/badge/pt__BR-91.12%25-yellow)
5046

5147
<details>
52-
<summary>Missing Keys</summary>
48+
<summary>Missing keys in pt_BR.axaml</summary>
5349

5450
- Text.AIAssistant.Regen
5551
- Text.AIAssistant.Use
@@ -120,32 +116,8 @@
120116

121117
</details>
122118

123-
### ru_RU.axaml: 100.00%
124-
125-
126-
<details>
127-
<summary>Missing Keys</summary>
128-
129-
130-
131-
</details>
132-
133-
### zh_CN.axaml: 100.00%
119+
### ![ru__RU](https://img.shields.io/badge/ru__RU-%E2%88%9A-brightgreen)
134120

121+
### ![zh__CN](https://img.shields.io/badge/zh__CN-%E2%88%9A-brightgreen)
135122

136-
<details>
137-
<summary>Missing Keys</summary>
138-
139-
140-
141-
</details>
142-
143-
### zh_TW.axaml: 100.00%
144-
145-
146-
<details>
147-
<summary>Missing Keys</summary>
148-
149-
150-
151-
</details>
123+
### ![zh__TW](https://img.shields.io/badge/zh__TW-%E2%88%9A-brightgreen)

build/scripts/localization-check.js

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const repoRoot = path.join(__dirname, '../../');
66
const localesDir = path.join(repoRoot, 'src/Resources/Locales');
77
const enUSFile = path.join(localesDir, 'en_US.axaml');
88
const outputFile = path.join(repoRoot, 'TRANSLATION.md');
9-
const readmeFile = path.join(repoRoot, 'README.md');
109

1110
const parser = new xml2js.Parser();
1211

@@ -18,46 +17,36 @@ async function parseXml(filePath) {
1817
async function calculateTranslationRate() {
1918
const enUSData = await parseXml(enUSFile);
2019
const enUSKeys = new Set(enUSData.ResourceDictionary['x:String'].map(item => item.$['x:Key']));
21-
22-
const translationRates = [];
23-
const badges = [];
24-
2520
const files = (await fs.readdir(localesDir)).filter(file => file !== 'en_US.axaml' && file.endsWith('.axaml'));
2621

27-
// Add en_US badge first
28-
badges.push(`[![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen)](TRANSLATION.md)`);
22+
const lines = [];
23+
24+
lines.push('# Translation Status');
25+
lines.push('This document shows the translation status of each locale file in the repository.');
26+
lines.push(`## Details`);
27+
lines.push(`### ![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen)`);
2928

3029
for (const file of files) {
30+
const locale = file.replace('.axaml', '').replace('_', '__');
3131
const filePath = path.join(localesDir, file);
3232
const localeData = await parseXml(filePath);
3333
const localeKeys = new Set(localeData.ResourceDictionary['x:String'].map(item => item.$['x:Key']));
34-
3534
const missingKeys = [...enUSKeys].filter(key => !localeKeys.has(key));
36-
const translationRate = ((enUSKeys.size - missingKeys.length) / enUSKeys.size) * 100;
3735

38-
translationRates.push(`### ${file}: ${translationRate.toFixed(2)}%\n`);
39-
translationRates.push(`<details>\n<summary>Missing Keys</summary>\n\n${missingKeys.map(key => `- ${key}`).join('\n')}\n\n</details>`);
36+
if (missingKeys.length > 0) {
37+
const progress = ((enUSKeys.size - missingKeys.length) / enUSKeys.size) * 100;
38+
const badgeColor = progress >= 75 ? 'yellow' : 'red';
4039

41-
// Add badges
42-
const locale = file.replace('.axaml', '').replace('_', '__');
43-
if (translationRate === 100) {
44-
badges.push(`[![${locale}](https://img.shields.io/badge/${locale}-%E2%88%9A-brightgreen)](TRANSLATION.md)`);
40+
lines.push(`### ![${locale}](https://img.shields.io/badge/${locale}-${progress.toFixed(2)}%25-${badgeColor})`);
41+
lines.push(`<details>\n<summary>Missing keys in ${file}</summary>\n\n${missingKeys.map(key => `- ${key}`).join('\n')}\n\n</details>`)
4542
} else {
46-
const badgeColor = translationRate >= 75 ? 'yellow' : 'red';
47-
badges.push(`[![${locale}](https://img.shields.io/badge/${locale}-${translationRate.toFixed(2)}%25-${badgeColor})](TRANSLATION.md)`);
48-
}
43+
lines.push(`### ![${locale}](https://img.shields.io/badge/${locale}-%E2%88%9A-brightgreen)`);
44+
}
4945
}
5046

51-
console.log(translationRates.join('\n\n'));
52-
53-
await fs.writeFile(outputFile, translationRates.join('\n\n') + '\n', 'utf8');
54-
55-
// Update README.md
56-
let readmeContent = await fs.readFile(readmeFile, 'utf8');
57-
const badgeSection = `## Translation Status\n\n${badges.join(' ')}`;
58-
console.log(badgeSection);
59-
readmeContent = readmeContent.replace(/## Translation Status\n\n.*\n\n/, badgeSection + '\n\n');
60-
await fs.writeFile(readmeFile, readmeContent, 'utf8');
47+
const content = lines.join('\n\n');
48+
console.log(content);
49+
await fs.writeFile(outputFile, content, 'utf8');
6150
}
6251

6352
calculateTranslationRate().catch(err => console.error(err));

0 commit comments

Comments
 (0)