blob: 4194340af18c81caf7b60b738c39438fa8f13495 (
plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!/usr/bin/env bash
#
# Copyright 2005-2019 The Mumble Developers. All rights reserved.
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file at the root of the
# Mumble source tree or at <https://www.mumble.info/LICENSE>.
# Updates mumble_en.ts from source and adds a commit.
#
# The main actions this script performs:
# * lupdate to update translation strings
# * Duplicate single 'numerusform' entries in mumble_en.ts to work around #1195
# * Commit the resulting translation file
#
# Requires qt5 ; sudo apt-get install libqt5-dev
# As the QT project files are parsed, additional qt dependencies apply;
# sudo apt-get install libqt5svg5-dev
set -u
set -e
file="mumble_en.ts"
dir="`dirname $0`/../src/mumble"
# Make sure we are using
export QT_SELECT=5
tmpfile="commitmessage.tmp"
function requireCommand
{
local c=$1
command -v $c >/dev/null 2>&1 || { printError "The required command $c is not available." >&2; exit 1; }
}
function checkRequirements
{
requireCommand lupdate
requireCommand qmake
requireCommand perl
requireCommand git
}
function printError
{
echo -e "\e[1;31mERROR\e[0m: $1"
}
function fatal
{
local msg="${1:-"Exiting because a command returned the error code $code"}"
printError "$msg"
exit 1
}
function main
{
checkRequirements
if ! [[ -f "$dir/$file" ]];
then
printError "Could not find file '${file}'."
exit 1
fi
pushd "$dir" >/dev/null
trap 'code=$? ; popd >/dev/null; exit $code' INT TERM EXIT
if [[ -n $(git status --porcelain $file) ]] ; then
printError "The file $file has local changes."
exit 1
fi
echo "Translation update" > $tmpfile
echo "" >> $tmpfile
lupdate -no-ui-lines -disable-heuristic similartext -locations relative -no-obsolete mumble.pro -ts $file | tee -a $tmpfile || fatal "lupdate failed"
echo
# Duplicate single numerusform entries in mumble_en.ts to work around #1195
perl -pi -e 's!(^\s*)(<numerusform></numerusform>)$!\1\2\2!' $file || (rm $tmpfile ; fatal "Workardound for #1195 failed - in-place replacement via perl.")
if ! [[ -n $(git status --porcelain $file) ]] ; then
echo "No translation changes. Nothing to commit."
rm $tmpfile
exit 0
fi
echo "Committing changes ..."
git commit -F $tmpfile $file || (rm $tmpfile ; fatal "Failed to commit the changes")
rm $tmpfile || printError "Failed to remove temporary file '$tmpfile'"
echo "Probably done."
echo
echo "Before pushing, _manually_ check the output above as well as the commits changes."
echo "An lupdate warning about overriding TRANSLATIONS is expected, as well as \"removal of plural forms\". Any project errors (missing qt modules) however are not, and the resulting changes must not be pushed."
popd >/dev/null
trap - INT TERM EXIT
}
main
|