Skip to content

Commit

Permalink
Merge pull request #69255 from BrettDong/discard_invalid_po
Browse files Browse the repository at this point in the history
Discard invalid PO files in pull translations GHA workflow
  • Loading branch information
Maleclypse authored Nov 11, 2023
2 parents 8e12218 + 40e9497 commit b553335
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pull-translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
run: tx pull --force
- name: "Discard invalid translations"
run: ./lang/discard_invalid_po.sh
- name: "Update stats"
run: ./lang/update_stats.sh
- name: Create Pull Request
Expand Down
19 changes: 19 additions & 0 deletions lang/discard_invalid_po.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Sometimes PO files pulled from Transifex are not accepted by GNU gettext, for example
# lang/po/hu.po:430257: 'msgid' and 'msgstr' entries do not both begin with '\n'
# lang/po/hu.po:534682: 'msgid' and 'msgstr' entries do not both end with '\n'
# lang/po/hu.po:534692: 'msgid' and 'msgstr' entries do not both end with '\n'
#
# This script tries to compile each updated PO file, and revert PO files that cannot be compiled by GNU gettext.
# So the invalid PO files won't fail Basic Build CI test and block merging the i18n update pull requests.

function discard_po() {
echo Discarding $1
git restore $1
}

for i in $(git diff --name-only lang/po/*.po); do
msgfmt -o /dev/null $i || discard_po $i
done

0 comments on commit b553335

Please sign in to comment.