chore(readme): order languages alphabetically

This commit is contained in:
Elian Doran
2025-12-08 13:03:32 +02:00
parent ce5a775160
commit 3ee8eac635
3 changed files with 12 additions and 14 deletions

View File

@@ -5,16 +5,6 @@ const scriptDir = __dirname;
const rootDir = join(scriptDir, "../..");
const docsDir = join(rootDir, "docs");
/**
* The base file is used by Weblate when generating new languages for the README file.
* The problem is that translated READMEs reside in `/docs/` while the main README is in `/`, which breaks all relative links.
* As such, we need to use a separate base file that is in `/docs` with the right relative paths.
* The README in the repo root remains the true base file, but it's a two-step process which requires the execution of this script.
*/
async function handleBaseFile() {
}
async function getLanguageStats() {
const cacheFile = join(scriptDir, ".language-stats.json");
@@ -47,8 +37,10 @@ async function getLanguageStats() {
async function rewriteLanguageBar(readme: string) {
// Filter languages by their availability.
const languageStats = await getLanguageStats();
const languagesWithCoverage = languageStats.results.filter(language => language.translated_percent > 75);
const languageLinks = languagesWithCoverage.map(language => `[${language.language.name}](./${language.filename})`)
const languagesWithCoverage: any[] = languageStats.results.filter(language => language.translated_percent > 75);
const languageLinks = languagesWithCoverage
.map(language => `[${language.language.name}](./${language.filename})`)
.toSorted((a, b) => a.localeCompare(b));
readme = readme.replace(
/<!-- LANGUAGE SWITCHER -->\r?\n.*$/m,
@@ -62,6 +54,12 @@ function rewriteRelativeLinks(readme: string) {
return readme;
}
/**
* The base file is used by Weblate when generating new languages for the README file.
* The problem is that translated READMEs reside in `/docs/` while the main README is in `/`, which breaks all relative links.
* As such, we need to use a separate base file that is in `/docs` with the right relative paths.
* The README in the repo root remains the true base file, but it's a two-step process which requires the execution of this script.
*/
async function main() {
// Read the README at root level.
const readmePath = join(rootDir, "README.md");