A local-first personal finance app
Exclude untranslated languages from builds (#4148)
Julian Dominguez-Schatz5d91d29d77ae
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.ymlindex f0ac4b33ce..eb0cd07a65 100644--- a/.github/actions/setup/action.yml+++ b/.github/actions/setup/action.yml@@ -38,3 +38,7 @@ runs:repository: actualbudget/translationspath: ${{ inputs.working-directory }}/packages/desktop-client/localeif: ${{ inputs.download-translations == 'true' }}+ - name: Remove untranslated languages+ run: packages/desktop-client/bin/remove-untranslated-languages+ shell: bash+ if: ${{ inputs.download-translations == 'true' }}diff --git a/bin/package-browser b/bin/package-browserindex 955d98f732..6565d42995 100755--- a/bin/package-browser+++ b/bin/package-browser@@ -11,6 +11,7 @@ fipushd packages/desktop-client/locale > /dev/nullgit pullpopd > /dev/null+packages/desktop-client/bin/remove-untranslated-languagesyarn workspace loot-core build:browseryarn workspace @actual-app/web build:browserdiff --git a/packages/desktop-client/bin/remove-untranslated-languages b/packages/desktop-client/bin/remove-untranslated-languagesnew file mode 100755index 0000000000..c3dd650610--- /dev/null+++ b/packages/desktop-client/bin/remove-untranslated-languages@@ -0,0 +1,48 @@+#!/usr/bin/env node+const fs = require('fs');+const path = require('path');++// Local path to the cloned translations repository+const localRepoPath = './packages/desktop-client/locale';++// Compare JSON files and delete incomplete ones+const processTranslations = () => {+ try {+ const files = fs.readdirSync(localRepoPath);+ const enJsonPath = path.join(localRepoPath, 'en.json');++ if (!fs.existsSync(enJsonPath)) {+ throw new Error('en.json not found in the repository.');+ }++ const enJson = JSON.parse(fs.readFileSync(enJsonPath, 'utf8'));+ const enKeysCount = Object.keys(enJson).length;++ console.log(`en.json has ${enKeysCount} keys.`);++ files.forEach((file) => {+ if (file === 'en.json' || path.extname(file) !== '.json') return;++ const filePath = path.join(localRepoPath, file);+ const jsonData = JSON.parse(fs.readFileSync(filePath, 'utf8'));+ const fileKeysCount = Object.keys(jsonData).length;++ // Calculate the percentage of keys present compared to en.json+ const percentage = (fileKeysCount / enKeysCount) * 100;+ console.log(`${file} has ${fileKeysCount} keys (${percentage.toFixed(2)}%).`);++ if (percentage < 50) {+ fs.unlinkSync(filePath);+ console.log(`Deleted ${file} due to insufficient keys.`);+ } else {+ console.log(`Keeping ${file}.`);+ }+ });++ console.log('Processing completed.');+ } catch (error) {+ console.error(`Error: ${error.message}`);+ }+};++processTranslations();diff --git a/upcoming-release-notes/4148.md b/upcoming-release-notes/4148.mdnew file mode 100644index 0000000000..30292735b1--- /dev/null+++ b/upcoming-release-notes/4148.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [jfdoming]+---++Exclude untranslated languages from builds