Skip to content

Commit 94f9316

Browse files
committed
chore(dev): add translation workflow
1 parent d693f16 commit 94f9316

3 files changed

Lines changed: 93 additions & 1 deletion

File tree

.github/workflows/translations.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Translations Diff
2+
3+
on:
4+
pull_request_review:
5+
pull_request:
6+
types: [opened, edited, synchronize, ready_for_review]
7+
branches:
8+
- development
9+
- master
10+
11+
jobs:
12+
translation:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Base Branch
16+
uses: actions/checkout@master
17+
with:
18+
ref: ${{ github.base_ref }}
19+
path: visualizer-base
20+
- name: Setup node 22
21+
uses: actions/setup-node@v6
22+
with:
23+
node-version: 22.x
24+
- name: Checkout PR Branch (Head)
25+
uses: actions/checkout@master
26+
with:
27+
path: visualizer-head
28+
- name: Build POT for PR Branch
29+
run: |
30+
chmod +x ./visualizer-head/bin/make-pot.sh
31+
./visualizer-head/bin/make-pot.sh ./visualizer-head ./visualizer-head/languages/visualizer.pot
32+
ls ./visualizer-head/languages/
33+
- name: Build POT for Base Branch
34+
run: |
35+
./visualizer-head/bin/make-pot.sh ./visualizer-base ./visualizer-base/languages/visualizer.pot
36+
ls ./visualizer-base/languages/
37+
- name: Compare POT files
38+
uses: Codeinwp/action-i18n-string-reviewer@main
39+
with:
40+
fail-on-changes: "false"
41+
openrouter-key: ${{ secrets.OPEN_ROUTER_API_KEY }}
42+
openrouter-model: "google/gemini-2.5-flash"
43+
base-pot-file: "visualizer-base/languages/visualizer.pot"
44+
target-pot-file: "visualizer-head/languages/visualizer.pot"
45+
github-token: ${{ secrets.BOT_TOKEN }}

.wp-env.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"core": "WordPress/WordPress#6.5.0",
2+
"core": null,
33
"phpVersion": "7.4",
44
"plugins": ["."],
55
"themes": [],

bin/make-pot.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# Script to generate POT file via Docker
4+
# Usage: ./bin/make-pot.sh [plugin-path] [destination-path]
5+
6+
# Set defaults
7+
PLUGIN_PATH="${1:-.}"
8+
DESTINATION="${2:-.}"
9+
10+
# Resolve absolute paths
11+
PLUGIN_PATH="$(cd "$PLUGIN_PATH" 2>/dev/null && pwd)" || {
12+
echo "Error: Plugin path '$1' does not exist"
13+
exit 1
14+
}
15+
16+
DESTINATION="$(cd "$(dirname "$DESTINATION")" 2>/dev/null && pwd)/$(basename "$DESTINATION")" || {
17+
echo "Error: Unable to resolve destination path"
18+
exit 1
19+
}
20+
21+
# Extract destination filename and directory
22+
DEST_DIR="$(dirname "$DESTINATION")"
23+
DEST_FILE="$(basename "$DESTINATION")"
24+
25+
# Ensure destination directory exists
26+
mkdir -p "$DEST_DIR"
27+
28+
echo "Generating POT file..."
29+
echo "Plugin Path: $PLUGIN_PATH"
30+
echo "Destination: $DESTINATION"
31+
echo ""
32+
33+
# Run Docker container with wp-cli to generate POT
34+
docker run --user root --rm \
35+
--volume "$PLUGIN_PATH:/var/www/html/plugin" \
36+
wordpress:cli \
37+
bash -c 'php -d memory_limit=512M "$(which wp)" --version --allow-root && wp i18n make-pot plugin ./plugin/languages/'"$DEST_FILE"' --include=admin,includes,libs,assets,views --allow-root --domain=anti-spam'
38+
39+
# Check if the file was created inside the container
40+
if [ $? -eq 0 ]; then
41+
echo ""
42+
echo "✓ POT file successfully generated at: $DESTINATION"
43+
else
44+
echo ""
45+
echo "✗ Error generating POT file"
46+
exit 1
47+
fi

0 commit comments

Comments
 (0)