From 395092099a9dbf5b54a122721843afaaeb6bb713 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 1 Sep 2024 01:18:24 +0200 Subject: [PATCH] [SKIP CI][Tooling] Update translation changelog script Weblate changed the language names of chinese simplified and traditional to include "Han script". This messed up the updated language detection --- tools/scripts/createTranslationChangelog.ts | 25 ++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tools/scripts/createTranslationChangelog.ts b/tools/scripts/createTranslationChangelog.ts index 89ab328b..728cb706 100644 --- a/tools/scripts/createTranslationChangelog.ts +++ b/tools/scripts/createTranslationChangelog.ts @@ -178,7 +178,7 @@ const getUsername = async (url: string, authToken: string): Promise => { const getLanguageName = async (url: string, authToken: string): Promise => { const languagePayload = await fetchData(url, authToken); - return languagePayload.language.name; + return languagePayload.language.name.replace(/\(([a-zA-Z]+) Han script\)/g, '($1)'); }; const extractContributionInfoFromChanges = ( @@ -381,15 +381,20 @@ const createTranslationChangelog = async (): Promise => { 'Thank you for your contribution to the translation of the project.\n', ); - console.log('### Added'); - newLanguages.forEach(({ language, contributors }) => { - console.log(`- ${language} (by ${contributors.join(', ')})`); - }); - console.log(''); - console.log('### Updated'); - updatedLanguages.forEach(({ language, contributors }) => { - console.log(`- ${language} (by ${contributors.join(', ')})`); - }); + if (newLanguages.length) { + console.log('### Added'); + newLanguages.forEach(({ language, contributors }) => { + console.log(`- ${language} (by ${contributors.join(', ')})`); + }); + console.log(''); + } + + if (updatedLanguages.length) { + console.log('### Updated'); + updatedLanguages.forEach(({ language, contributors }) => { + console.log(`- ${language} (by ${contributors.join(', ')})`); + }); + } }; createTranslationChangelog();