diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml new file mode 100644 index 0000000000..515c88129a --- /dev/null +++ b/.github/workflows/translations.yml @@ -0,0 +1,30 @@ +name: Check Translation Changes + +on: + pull_request: + paths: + - "src/i18n/locales/en/translation.json" + types: + - opened + - synchronize + +jobs: + check_translation_changes: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 2 # Fetch the base commit as well + + - uses: actions/setup-node@v3 + + - name: Check for Translation Changes + run: | + file_path="src/i18n/locales/en/translation.json" + branch_name=${{ github.ref }} + url="https://api.github.com/repos/${{ github.repository }}/contents/${file_path}?ref=${branch_name}" + echo $url + BASE_CONTENT=$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $url | jq -c -r .content | base64 -d | jq -c .) + node scripts/check-changed-translations.js "$BASE_CONTENT" diff --git a/scripts/check-changed-translations.js b/scripts/check-changed-translations.js new file mode 100644 index 0000000000..e01e42a3a3 --- /dev/null +++ b/scripts/check-changed-translations.js @@ -0,0 +1,27 @@ +const fs = require("fs"); + +const previousData = JSON.parse(process.argv[2]); + +const currentContent = fs.readFileSync( + "src/i18n/locales/en/translation.json", + "utf8" +); + +const currentData = JSON.parse(currentContent); + +function compareObjects(obj1, obj2) { + for (const key in obj1) { + console.log("checking", key); + if (obj1.hasOwnProperty(key)) { + if (typeof obj1[key] === "object" && typeof obj2[key] === "object") { + compareObjects(obj1[key], obj2[key]); + } else if (obj1[key] !== obj2[key]) { + console.log(`Value of key "${key}" has changed:`); + console.log(`Previous: ${obj1[key]}`); + console.log(`Current: ${obj2[key]}`); + } + } + } +} + +compareObjects(previousData, currentData); diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json index 7e8241b9e1..689ce8c639 100644 --- a/src/i18n/locales/en/translation.json +++ b/src/i18n/locales/en/translation.json @@ -1,7 +1,7 @@ { "translation": { "welcome": { - "title": "Welcome to Alby", + "title": "Welcome to Alby 2", "set_password": { "title": "Set an unlock passcode", "description": "This passcode will allow you to unlock Alby on this device. It cannot be recovered, but may be changed later.",