Skip to content

Commit 5c1e5f2

Browse files
committed
Actions (translations): Enforce that .pot and .po files are in sync
1 parent 7c668c3 commit 5c1e5f2

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

.github/workflows/translations.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#! /usr/bin/env bash
2+
set -e -u -o pipefail
3+
4+
restore_po_creation_date_from_git() {
5+
local filename="${1}"
6+
local original="$(git show "HEAD:./${filename}" 2>/dev/null | grep -nF POT-Creation-Date:)"
7+
if [[ -z ${original} ]]; then
8+
echo "[*] Skipped unversioned file \"${filename}\"."
9+
return 0
10+
fi
11+
local line_number="${original%%:*}"
12+
local line_content="${original#*:}"
13+
{
14+
sed -n "1,$(( line_number - 1 ))p" "${filename}"
15+
echo "${line_content}"
16+
sed -n "$(( line_number + 1 )),\$p" "${filename}"
17+
} | sponge "${filename}"
18+
echo "[+] Restored POT-Creation-Date for file \"${filename}\"."
19+
}
20+
21+
gettext --version | head -n1
22+
23+
echo '[*] Update existing .pot files...'
24+
for i in libvisual libvisual-plugins ; do
25+
make -C "${i}"/po update-pot >/dev/null
26+
done
27+
28+
echo '[*] Update existing .po files...'
29+
for i in libvisual libvisual-plugins ; do
30+
make -C "${i}"/po update-po >/dev/null
31+
done
32+
33+
echo '[*] Restoring creation date headers...'
34+
for i in */po/*.{po,pot}; do
35+
restore_po_creation_date_from_git "${i}"
36+
done
37+
38+
echo '[+] DONE.'

.github/workflows/translations.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Enforce that .po/.pot files are in sync with the code
2+
3+
on:
4+
pull_request:
5+
push:
6+
schedule:
7+
- cron: '0 3 * * 5' # Every Friday at 3am
8+
9+
env:
10+
LV_INSTALL_PREFIX: /home/runner/.local/
11+
12+
jobs:
13+
translations:
14+
name: Enforce that .po/.pot files are in sync with the code
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Install build dependencies
18+
run: |-
19+
sudo apt-get update
20+
# Note: This additional step's sole purpuse is to workaround symptom:
21+
# > The following packages have unmet dependencies:
22+
# > libunwind-14-dev : Breaks: libunwind-dev but 1.3.2-2build2
23+
# > is to be installed
24+
sudo apt-get install --yes --no-install-recommends libunwind-dev
25+
sudo apt-get install --yes --no-install-recommends \
26+
autopoint \
27+
bison \
28+
doxygen \
29+
flex \
30+
gettext \
31+
graphviz \
32+
libgstreamer1.0-dev \
33+
libgtk2.0-dev \
34+
libjack-dev \
35+
libluajit-5.1-dev \
36+
liborc-0.4-dev \
37+
libpng-dev \
38+
libasound2-dev \
39+
libsdl1.2-dev \
40+
libgl1-mesa-dev \
41+
moreutils \
42+
pkg-config
43+
44+
- name: Checkout Git branch
45+
uses: actions/checkout@v3
46+
47+
- name: '[LV] Run autoreconf'
48+
run: |-
49+
for i in libvisual libvisual-plugins ; do
50+
pushd ${i}
51+
autoreconf --install --verbose --force
52+
popd
53+
done
54+
55+
- name: '[LV] Run "./configure" (from Git)'
56+
run: |-
57+
cd libvisual
58+
./configure \
59+
--prefix ${LV_INSTALL_PREFIX} \
60+
61+
- name: '[LV] Run "make"'
62+
run: |-
63+
make -C libvisual -j2 VERBOSE=1
64+
65+
- name: '[LV] Run "make install"'
66+
run: |-
67+
make -C libvisual install
68+
find ${LV_INSTALL_PREFIX} | sort
69+
70+
- name: '[Plugins] Run "./configure" (from Git)'
71+
run: |-
72+
cd libvisual-plugins
73+
PKG_CONFIG_PATH=${LV_INSTALL_PREFIX}/lib/pkgconfig/ \
74+
./configure \
75+
--disable-gstreamer-plugin \
76+
77+
- name: 'Enforce that .po/.pot files are in sync with the code'
78+
run: |-
79+
.github/workflows/translations.sh
80+
git diff --exit-code # i.e. fail CI with details if non-empty

0 commit comments

Comments
 (0)