From 0980e4a3b63104a5bd1cc8c73bcfc9ffc3631d13 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 22 Mar 2025 23:02:54 -0700 Subject: [PATCH 1/2] Chore: auto-translate strings --- .github/workflows/translate-strings.yml | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/translate-strings.yml diff --git a/.github/workflows/translate-strings.yml b/.github/workflows/translate-strings.yml new file mode 100644 index 000000000..e453a0a93 --- /dev/null +++ b/.github/workflows/translate-strings.yml @@ -0,0 +1,68 @@ +name: Generate Translation Strings +on: + push: + branches: + - dev +jobs: + generate-translate-strings: + name: Generate Translation Strings + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + - name: Set up Python + id: setup-python + uses: actions/setup-python@v5 + - name: Install system dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -qq --no-install-recommends gettext + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + - name: Install backend python dependencies + run: | + uv sync \ + --group dev \ + --frozen + - name: Generate backend translation strings + run: cd src/ && uv run manage.py makemessages -l en_US -i "samples*" + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: 'pnpm' + cache-dependency-path: 'src-ui/pnpm-lock.yaml' + - name: Cache frontend dependencies + id: cache-frontend-deps + uses: actions/cache@v4 + with: + path: | + ~/.pnpm-store + ~/.cache + key: ${{ runner.os }}-frontenddeps-${{ hashFiles('src-ui/pnpm-lock.yaml') }} + - name: Install frontend dependencies + if: steps.cache-frontend-deps.outputs.cache-hit != 'true' + run: cd src-ui && pnpm install + - name: Re-link Angular cli + run: cd src-ui && pnpm link @angular/cli + - name: Generate frontend translation strings + run: | + cd src-ui + pnpm run ng extract-i18n + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + file_pattern: 'src-ui/messages.xlf src/locale/en_US/LC_MESSAGES/django.po' + commit_message: "Auto translate strings" + commit_user_name: "GitHub Actions" + commit_author: "GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>" From 56673256a83506ac42e7f38da499558ea4307765 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 22 Mar 2025 23:38:55 -0700 Subject: [PATCH 2/2] Need to use a PAT for protected branch --- .github/workflows/translate-strings.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/translate-strings.yml b/.github/workflows/translate-strings.yml index e453a0a93..4a4ae1885 100644 --- a/.github/workflows/translate-strings.yml +++ b/.github/workflows/translate-strings.yml @@ -13,6 +13,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: + token: ${{ secrets.PNGX_BOT_PAT }} ref: ${{ github.head_ref }} - name: Set up Python id: setup-python