Skip to content

Fixes

Fixes #3

name: Update Translation File
on:
push:
branches: [ main ]
paths:
- '*.php'
- '**/*.php'
- '*.js'
- '**/*.js'
- '.github/workflows/update-pot-file.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
issues: write
env:
PLUGIN_SLUG: enginescript-site-exporter
POT_FILE: languages/enginescript-site-exporter.pot
jobs:
update-pot:
name: Regenerate .pot File
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none
- name: Install WP-CLI
run: |
curl -fsSL -o wp-cli.phar https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp --version
wp help i18n make-pot >/dev/null
- name: Regenerate .pot file
run: |
mkdir -p "$(dirname "$POT_FILE")"
wp i18n make-pot . "$POT_FILE" \
--slug="$PLUGIN_SLUG" \
--domain="$PLUGIN_SLUG" \
--skip-audit \
--exclude=vendor,node_modules,tests,build,plugin-check-build,.git,.github
test -f "$POT_FILE"
- name: Check for changes
id: changes
run: |
if git diff --quiet --ignore-matching-lines='^"POT-Creation-Date:' -- "$POT_FILE"; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
echo "Translation file is up to date"
git restore -- "$POT_FILE"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
echo "Translation file updated"
git diff --ignore-matching-lines='^"POT-Creation-Date:' -- "$POT_FILE" | head -80
fi
- name: Create Pull Request
if: steps.changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v8
with:
commit-message: 'chore(i18n): regenerate translation template'
title: 'chore(i18n): Update translation template (.pot file)'
body: |
## Translation Template Update
This PR updates the translation template (`.pot` file) based on recent code changes.
### What Changed
The following PHP and JavaScript source files had translatable strings added or modified.
See the diff in this PR for details.
### Next Steps
1. Review the changes in the `.pot` file
2. Approve and merge this PR
3. Translators can then use the updated `.pot` file with their translation tools
---
*This PR was automatically generated by the [Update Translation File](https://github.com/${{ github.repository }}/blob/main/.github/workflows/update-pot-file.yml) workflow.*
add-paths: ${{ env.POT_FILE }}
branch: chore/update-pot-file
base: main
delete-branch: true
labels: 'automation,maintenance'