Skip to content

Commit 662cb0f

Browse files
Update transifex-pull.yml
1 parent 9607d2f commit 662cb0f

1 file changed

Lines changed: 15 additions & 17 deletions

File tree

‎.github/workflows/transifex-pull.yml‎

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,23 @@ jobs:
4545
git config --local user.email github-actions@github.com
4646
git config --local user.name "GitHub Action's update-translation job"
4747
48-
# 1. SMART METRIC INSPECTION: Protect GitHub work from empty or degraded pulls
49-
- name: Protect GitHub translations from empty Transifex overwrites
48+
# 1. FAIL-SAFE PROTECTION: Restore any file that Transifex deleted or stripped of content
49+
- name: Protect GitHub translations from Transifex overwrites
5050
run: |
5151
git diff --name-only | grep '\.po$' | while read file; do
52-
if [ -f "$file" ]; then
53-
# Export the committed GitHub variant to a temporary path
54-
git show HEAD:"$file" > /tmp/github_version.po 2>/dev/null || echo "" > /tmp/github_version.po
55-
56-
# Extract and isolate valid translated msgids using standard gettext tooling
57-
GITHUB_COUNT=$(msgattrib --translated /tmp/github_version.po 2>/dev/null | grep -c '^msgid' || echo 0)
58-
TRANSIFEX_COUNT=$(msgattrib --translated "$file" 2>/dev/null | grep -c '^msgid' || echo 0)
59-
60-
echo "Inspecting $file -> GitHub translations count: $GITHUB_COUNT, Transifex count: $TRANSIFEX_COUNT"
61-
62-
# If GitHub holds more verified strings, reject the incoming database change
63-
if [ "$GITHUB_COUNT" -gt "$TRANSIFEX_COUNT" ]; then
64-
echo "CRITICAL WARNING: Transifex payload is missing strings. Reverting file to GitHub baseline."
65-
git checkout HEAD -- "$file"
66-
fi
52+
53+
# Catch file deletions from the delete_obsolete_files step
54+
if [ ! -f "$file" ]; then
55+
echo "CRITICAL: Transifex deleted $file. Restoring from GitHub baseline!"
56+
git checkout HEAD -- "$file"
57+
continue
58+
fi
59+
60+
# Catch string subtractions (lines starting with '-' that had active translations)
61+
REMOVED_TRANSLATIONS=$(git diff HEAD -- "$file" | grep '^-msgstr "[^"]' || true)
62+
if [ ! -z "$REMOVED_TRANSLATIONS" ]; then
63+
echo "CRITICAL: Transifex stripped translations from $file. Restoring from GitHub baseline!"
64+
git checkout HEAD -- "$file"
6765
fi
6866
done || true
6967

0 commit comments

Comments
 (0)