Browse Source

Fixed download conditions

CPK 5 months ago
parent
commit
0dcc9bcc6b

+ 6 - 5
.github/workflows/localization.yml

@@ -22,8 +22,6 @@ jobs:
   compare-upload:
   compare-upload:
     name: "Compare local English"
     name: "Compare local English"
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
-    outputs:
-      hasChanges: ${{ steps.upload-comparison.outputs.HAS_CHANGES }}
     if: ${{ inputs.mode != 'Download only' }}
     if: ${{ inputs.mode != 'Download only' }}
     steps:
     steps:
       - name: Checkout
       - name: Checkout
@@ -34,6 +32,8 @@ jobs:
         env:
         env:
           POEDITOR_API_KEY: ${{ secrets.POEDITORKEY }}
           POEDITOR_API_KEY: ${{ secrets.POEDITORKEY }}
           POEDITOR_PROJECT_ID: ${{ secrets.POEDITORPROJECT }}
           POEDITOR_PROJECT_ID: ${{ secrets.POEDITORPROJECT }}
+    outputs:
+      hasChanges: ${{ steps.upload-comparison.outputs.HAS_CHANGES }}
 
 
   upload:
   upload:
     name: "Upload English changes"
     name: "Upload English changes"
@@ -64,20 +64,21 @@ jobs:
           POEDITOR_API_KEY: ${{ secrets.POEDITORKEY }}
           POEDITOR_API_KEY: ${{ secrets.POEDITORKEY }}
           POEDITOR_PROJECT_ID: ${{ secrets.POEDITORPROJECT }}
           POEDITOR_PROJECT_ID: ${{ secrets.POEDITORPROJECT }}
       - name: Create branch
       - name: Create branch
-        if: ${{ steps.download-languages.outputs.hasChanges == 'true' }}
+        if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
         run: git checkout -B "language-update-${{ github.run_number }}-${{ github.run_attempt }}"
         run: git checkout -B "language-update-${{ github.run_number }}-${{ github.run_attempt }}"
       - name: Add changes and commit
       - name: Add changes and commit
+        if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
         run: |
         run: |
           git config --global user.name "github-actions[bot]"
           git config --global user.name "github-actions[bot]"
           git config --global user.email "github-actions[bot]@users.noreply.github.com"
           git config --global user.email "github-actions[bot]@users.noreply.github.com"
           git add -A
           git add -A
           git commit -m "Update language files"
           git commit -m "Update language files"
       - name: Push changes
       - name: Push changes
-        if: ${{ steps.download-languages.outputs.hasChanges == 'true' }}
+        if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
         run: |
         run: |
           git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
           git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
       # - name: Create Pull Request
       # - name: Create Pull Request
-      #   if: ${{ steps.download-languages.outputs.hasChanges == 'true' }}
+      #   if: ${{ steps.download-languages.outputs.HAS_CHANGES == 'true' }}
       #   run: |
       #   run: |
       #     gh pr create --title "Language Update ${{ github.run_number }}" \
       #     gh pr create --title "Language Update ${{ github.run_number }}" \
       #           --body "This PR was created automatically.
       #           --body "This PR was created automatically.

+ 3 - 3
.github/workflows/localization/download-languages.py

@@ -68,7 +68,7 @@ def update_locale_file(language):
     # Use "remote-code" if available, otherwise default to "code"
     # Use "remote-code" if available, otherwise default to "code"
     lang_code = language.get("remoteCode", language["code"])
     lang_code = language.get("remoteCode", language["code"])
     if language["code"].lower() == "en":
     if language["code"].lower() == "en":
-        return  # Skip English (do not update)
+        return False # Skip English (do not update)
 
 
     file_name = language["localeFileName"]
     file_name = language["localeFileName"]
     file_path = os.path.join(LOCALES_DIR, file_name)
     file_path = os.path.join(LOCALES_DIR, file_name)
@@ -76,7 +76,7 @@ def update_locale_file(language):
     remote_data = fetch_poeditor_language_json(lang_code)
     remote_data = fetch_poeditor_language_json(lang_code)
     if remote_data is None:
     if remote_data is None:
         print(f"::error::Skipping update for {language['name']} ({lang_code}) due to fetch error.")
         print(f"::error::Skipping update for {language['name']} ({lang_code}) due to fetch error.")
-        return
+        return False
 
 
     # Build new ordered data:
     # Build new ordered data:
     # 1. Start with keys from local file that exist in remote.
     # 1. Start with keys from local file that exist in remote.
@@ -93,7 +93,7 @@ def update_locale_file(language):
     if updated_data != local_data:
     if updated_data != local_data:
         write_ordered_json(file_path, updated_data)
         write_ordered_json(file_path, updated_data)
         print(f"✅ Updated locale file for {language['name']} ({language['code']}).")
         print(f"✅ Updated locale file for {language['name']} ({language['code']}).")
-        return False
+        return True
     else:
     else:
         print(f"✅ No changes for {language['name']} ({language['code']}).")
         print(f"✅ No changes for {language['name']} ({language['code']}).")
         return False
         return False