-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
51 lines (44 loc) · 1.56 KB
/
po-to-json-validation.yml
File metadata and controls
51 lines (44 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Convert PO to JSON and verify changes
on:
push:
paths:
- 'po/**/*.po'
jobs:
convert-and-verify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: true
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Find changed .po files
id: find_po
run: |
git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^po/.*\.po$' > changed_po_files.txt || true
cat changed_po_files.txt
echo "po_files<<EOF" >> $GITHUB_OUTPUT
echo "$(cat changed_po_files.txt)" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Convert PO files to JSON
if: steps.find_po.outputs.po_files != ''
run: |
mkdir -p locales
while IFS= read -r po_file; do
echo "▶ Converting $po_file"
python3 convert_po_to_json.py "$po_file" "locales"
done < changed_po_files.txt
- name: Verify JSON conversion changes
if: steps.find_po.outputs.po_files != ''
run: |
if ! git diff --quiet locales/; then
echo "❌ Generated translation JSON files have changes that need to be committed."
echo "Please run the PO-to-JSON conversion locally and commit the generated files in locales/."
exit 1
else
echo "✅ Translation JSON files are verified and up to date."
fi