From f32d10def332e41bbef6e787ed5cd46172342d6f Mon Sep 17 00:00:00 2001 From: Max Walters Date: Tue, 12 Dec 2023 21:15:42 -0500 Subject: [PATCH] feat: restart work on json file generator --- .github/workflows/po2json.yml | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/po2json.yml diff --git a/.github/workflows/po2json.yml b/.github/workflows/po2json.yml new file mode 100644 index 0000000..166d4ec --- /dev/null +++ b/.github/workflows/po2json.yml @@ -0,0 +1,48 @@ +name: Update Translations + +on: + push: + branches: "**" + pull_request: + types: + - opened + +jobs: + update-translations: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Install Dependencies + run: npm install -g po2json + + - name: Update Translations + run: | + project_folder="[project folder name]" + language_code="[language code of the language you are translating to]" + + # Find the .po file in the pushed changes + po_file=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep ".po") + + # If a .po file is found, update translations + if [ -n "$po_file" ]; then + po2json \ + $project_folder/$language_code.po \ + $project_folder/$language_code.json \ + -f jed \ + -d $language_code \ + --fallback-to-msgid + + git add . + git commit -m "Update translations" + git push + else + echo "No .po file found in the pushed changes. Skipping translation update." + fi