mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
ci: move all translation status to TRANSLATION.md
and do not modify README.md
while checking localization
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
cdc0fbb753
commit
39f4cd1732
3 changed files with 38 additions and 80 deletions
|
@ -18,7 +18,7 @@
|
||||||
* Supports SSH access with each remote
|
* Supports SSH access with each remote
|
||||||
* GIT commands with GUI
|
* GIT commands with GUI
|
||||||
* Clone/Fetch/Pull/Push...
|
* Clone/Fetch/Pull/Push...
|
||||||
* Merge/Rebase/Reset/Revert/Amend/Cherry-pick...
|
* Merge/Rebase/Reset/Revert/Cherry-pick...
|
||||||
* Amend/Reword/Squash
|
* Amend/Reword/Squash
|
||||||
* Interactive rebase
|
* Interactive rebase
|
||||||
* Branches
|
* Branches
|
||||||
|
@ -48,10 +48,7 @@
|
||||||
|
|
||||||
## Translation Status
|
## Translation Status
|
||||||
|
|
||||||
[](TRANSLATION.md) [](TRANSLATION.md) [](TRANSLATION.md) [](TRANSLATION.md) [](TRANSLATION.md) [](TRANSLATION.md) [](TRANSLATION.md) [](TRANSLATION.md) [](TRANSLATION.md)
|
You can find the current translation status in [TRANSLATION.md](TRANSLATION.md)
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> You can find the missing keys in [TRANSLATION.md](TRANSLATION.md)
|
|
||||||
|
|
||||||
## How to Use
|
## How to Use
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
### de_DE.axaml: 98.92%
|
# Translation Status
|
||||||
|
|
||||||
|
This document shows the translation status of each locale file in the repository.
|
||||||
|
|
||||||
|
## Details
|
||||||
|
|
||||||
|
### 
|
||||||
|
|
||||||
|
### 
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Missing Keys</summary>
|
<summary>Missing keys in de_DE.axaml</summary>
|
||||||
|
|
||||||
- Text.BranchUpstreamInvalid
|
- Text.BranchUpstreamInvalid
|
||||||
- Text.Configure.CustomAction.WaitForExit
|
- Text.Configure.CustomAction.WaitForExit
|
||||||
|
@ -15,41 +22,30 @@
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### es_ES.axaml: 99.87%
|
### 
|
||||||
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Missing Keys</summary>
|
<summary>Missing keys in es_ES.axaml</summary>
|
||||||
|
|
||||||
- Text.Preferences.General.ShowTagsInGraph
|
- Text.Preferences.General.ShowTagsInGraph
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### fr_FR.axaml: 100.00%
|
### 
|
||||||
|
|
||||||
|
### 
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Missing Keys</summary>
|
<summary>Missing keys in it_IT.axaml</summary>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
### it_IT.axaml: 99.87%
|
|
||||||
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Missing Keys</summary>
|
|
||||||
|
|
||||||
- Text.Preferences.General.ShowTagsInGraph
|
- Text.Preferences.General.ShowTagsInGraph
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### pt_BR.axaml: 91.12%
|
### 
|
||||||
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Missing Keys</summary>
|
<summary>Missing keys in pt_BR.axaml</summary>
|
||||||
|
|
||||||
- Text.AIAssistant.Regen
|
- Text.AIAssistant.Regen
|
||||||
- Text.AIAssistant.Use
|
- Text.AIAssistant.Use
|
||||||
|
@ -120,32 +116,8 @@
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### ru_RU.axaml: 100.00%
|
### 
|
||||||
|
|
||||||
|
### 
|
||||||
|
|
||||||
<details>
|
### 
|
||||||
<summary>Missing Keys</summary>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
### zh_CN.axaml: 100.00%
|
|
||||||
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Missing Keys</summary>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
### zh_TW.axaml: 100.00%
|
|
||||||
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Missing Keys</summary>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</details>
|
|
|
@ -6,7 +6,6 @@ const repoRoot = path.join(__dirname, '../../');
|
||||||
const localesDir = path.join(repoRoot, 'src/Resources/Locales');
|
const localesDir = path.join(repoRoot, 'src/Resources/Locales');
|
||||||
const enUSFile = path.join(localesDir, 'en_US.axaml');
|
const enUSFile = path.join(localesDir, 'en_US.axaml');
|
||||||
const outputFile = path.join(repoRoot, 'TRANSLATION.md');
|
const outputFile = path.join(repoRoot, 'TRANSLATION.md');
|
||||||
const readmeFile = path.join(repoRoot, 'README.md');
|
|
||||||
|
|
||||||
const parser = new xml2js.Parser();
|
const parser = new xml2js.Parser();
|
||||||
|
|
||||||
|
@ -18,46 +17,36 @@ async function parseXml(filePath) {
|
||||||
async function calculateTranslationRate() {
|
async function calculateTranslationRate() {
|
||||||
const enUSData = await parseXml(enUSFile);
|
const enUSData = await parseXml(enUSFile);
|
||||||
const enUSKeys = new Set(enUSData.ResourceDictionary['x:String'].map(item => item.$['x:Key']));
|
const enUSKeys = new Set(enUSData.ResourceDictionary['x:String'].map(item => item.$['x:Key']));
|
||||||
|
|
||||||
const translationRates = [];
|
|
||||||
const badges = [];
|
|
||||||
|
|
||||||
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
|
const lines = [];
|
||||||
badges.push(`[](TRANSLATION.md)`);
|
|
||||||
|
lines.push('# Translation Status');
|
||||||
|
lines.push('This document shows the translation status of each locale file in the repository.');
|
||||||
|
lines.push(`## Details`);
|
||||||
|
lines.push(`### `);
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
|
const locale = file.replace('.axaml', '').replace('_', '__');
|
||||||
const filePath = path.join(localesDir, file);
|
const filePath = path.join(localesDir, file);
|
||||||
const localeData = await parseXml(filePath);
|
const localeData = await parseXml(filePath);
|
||||||
const localeKeys = new Set(localeData.ResourceDictionary['x:String'].map(item => item.$['x:Key']));
|
const localeKeys = new Set(localeData.ResourceDictionary['x:String'].map(item => item.$['x:Key']));
|
||||||
|
|
||||||
const missingKeys = [...enUSKeys].filter(key => !localeKeys.has(key));
|
const missingKeys = [...enUSKeys].filter(key => !localeKeys.has(key));
|
||||||
const translationRate = ((enUSKeys.size - missingKeys.length) / enUSKeys.size) * 100;
|
|
||||||
|
|
||||||
translationRates.push(`### ${file}: ${translationRate.toFixed(2)}%\n`);
|
if (missingKeys.length > 0) {
|
||||||
translationRates.push(`<details>\n<summary>Missing Keys</summary>\n\n${missingKeys.map(key => `- ${key}`).join('\n')}\n\n</details>`);
|
const progress = ((enUSKeys.size - missingKeys.length) / enUSKeys.size) * 100;
|
||||||
|
const badgeColor = progress >= 75 ? 'yellow' : 'red';
|
||||||
|
|
||||||
// Add badges
|
lines.push(`### }%25-${badgeColor})`);
|
||||||
const locale = file.replace('.axaml', '').replace('_', '__');
|
lines.push(`<details>\n<summary>Missing keys in ${file}</summary>\n\n${missingKeys.map(key => `- ${key}`).join('\n')}\n\n</details>`)
|
||||||
if (translationRate === 100) {
|
|
||||||
badges.push(`[](TRANSLATION.md)`);
|
|
||||||
} else {
|
} else {
|
||||||
const badgeColor = translationRate >= 75 ? 'yellow' : 'red';
|
lines.push(`### `);
|
||||||
badges.push(`[}%25-${badgeColor})](TRANSLATION.md)`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(translationRates.join('\n\n'));
|
const content = lines.join('\n\n');
|
||||||
|
console.log(content);
|
||||||
await fs.writeFile(outputFile, translationRates.join('\n\n') + '\n', 'utf8');
|
await fs.writeFile(outputFile, content, 'utf8');
|
||||||
|
|
||||||
// Update README.md
|
|
||||||
let readmeContent = await fs.readFile(readmeFile, 'utf8');
|
|
||||||
const badgeSection = `## Translation Status\n\n${badges.join(' ')}`;
|
|
||||||
console.log(badgeSection);
|
|
||||||
readmeContent = readmeContent.replace(/## Translation Status\n\n.*\n\n/, badgeSection + '\n\n');
|
|
||||||
await fs.writeFile(readmeFile, readmeContent, 'utf8');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateTranslationRate().catch(err => console.error(err));
|
calculateTranslationRate().catch(err => console.error(err));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue