forked from MultiMC/Translations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·85 lines (66 loc) · 2.06 KB
/
update.sh
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
set -e
ROOT="$PWD"
SRC="$ROOT/src"
TEMPLATE_PO="$ROOT/template.pot"
TEMPLATE_TS="$ROOT/template.ts"
BASE_LST_FILE="$ROOT/base_lst_file"
LCONVERT_BIN=${LCONVERT_BIN:-lconvert-qt5}
LRELEASE_BIN=${LRELEASE_BIN:-lrelease-qt5}
LUPDATE_BIN=${LUPDATE_BIN:-lupdate-qt5}
###############################################################################
echo "Updating sources..."
if [ -d $SRC ]
then
echo " Updating existing sources"
cd $SRC
git fetch
git reset --hard origin/stable
cd $ROOT
else
echo " Cloning repo from scratch"
git clone https://github.com/MultiMC/MultiMC5.git $SRC
cd $SRC
git reset --hard origin/stable
cd $ROOT
fi
###############################################################################
echo "Writing lst file..."
cd $SRC
find -type f \( -iname \*.h -o -iname \*.cpp -o -iname \*.ui \) > $BASE_LST_FILE
cd $ROOT
echo " $(cat $BASE_LST_FILE | wc -l) files found"
###############################################################################
echo "Updating po template..."
if [ -f $TEMPLATE_PO ]
then
echo " Converting .pot to .ts"
$LCONVERT_BIN -locations relative $TEMPLATE_PO -o $TEMPLATE_TS
fi
echo " Updating .ts"
cd $SRC
$LUPDATE_BIN "@$BASE_LST_FILE" -ts $TEMPLATE_TS
cd $ROOT
echo " Converting .ts to .pot"
$LCONVERT_BIN -locations relative $TEMPLATE_TS -o $TEMPLATE_PO
echo " Removing .ts"
rm $TEMPLATE_TS
###############################################################################
echo "Updating .po files..."
for po_file in $(ls *.po)
do
# gets everything up to the first dot
lang=$(echo $po_file | grep -oP "^[^\.]*")
echo " Updating $po_file ($lang)"
msgmerge --lang=$lang --update --force-po $po_file $TEMPLATE_PO
done
###############################################################################
if [ -n "$MMC_TRANSLATIONS_REMOTE" ]
then
echo "Pushing changes to git"
git add $TEMPLATE_PO *.po
git commit -m "Update translations"
git push $MMC_TRANSLATIONS_REMOTE $(git rev-parse --abbrev-ref HEAD)
fi
###############################################################################
echo "All good!"