Debian Codegraph @

buildtools/update_locales

raw symbols SCIP
1 #!/bin/bash
2 aberr(){ printf "[\e[31mERROR\e[0m]: \e[1m%s\e[0m\n" "$*" >&2; }
3 abinfo(){ printf "[\e[96mINFO\e[0m]: \e[1m%s\e[0m\n" "$*" >&2; }
4
5 function upload_to_tx() {
6 if ! which tx > /dev/null; then
7 aberr "You don't have Transifex client installed. \n Run \`pip install transifex-client\` to install it."
8 exit 1
9 fi
10 abinfo "Uploading to transifex..."
11 if ! tx push -s; then
12 aberr "Problems occurred when uploading strings to Transifex."
13 printf "\t Either there are syntax errors in source file or you don't have permission to update the source file."
14 exit 1
15 fi
16 exit 0
17 }
18
19 function validate() {
20 ERR_LANG=""
21 ERR_BUF=""
22 for i in data/locale/*.ts; do
23 if ! ERR_BUF=$(lconvert-qt5 -i "${i}" -o "/tmp/test.qm" -of qm 2>&1); then
24 ERR_LANG+="\e[96m$(basename "${i}")\e[0m: \e[93m${ERR_BUF}\e[0m "
25 printf "\e[31mx\e[0m"
26 continue
27 fi
28 printf "\e[32m.\e[0m"
29 done
30 echo ""
31 if [[ "x${ERR_LANG}" != "x" ]]; then
32 aberr "The following files failed the validation: "
33 echo -e "${ERR_LANG}"
34 fi
35 }
36
37 abinfo "Checking for your environment..."
38 if ! which lupdate-qt5 > /dev/null; then
39 aberr "You don't seem to have Qt i18n tools installed."
40 printf "\tUsually this comes with your Qt installation, or you need to\n"
41 printf "\tinstall extra packages like \`qt5-tools\` or similar.\n"
42 exit 1;
43 fi
44
45 abinfo "Scanning directories..."
46
47 if test -d src/3rdparty/qt5-x11embed/3rdparty/ECM/; then
48 # prevent from collecting strings in ECM
49 rm -rf src/3rdparty/qt5-x11embed/3rdparty/ECM/
50 fi
51
52 if ! lupdate-qt5 -I include/ src/ plugins/ -ts data/locale/en.ts; then
53 aberr "There are some problems when collecting the strings."
54 exit 1
55 fi
56
57 abinfo "Validating translations..."
58 validate
59
60 abinfo "Translations successfully updated."
61 printf "Do you want to upload translations to Transifex? [y/N]: "
62 read -n 1 -r TX
63 echo ""
64
65 if [[ "$TX" == "y" || "$TX" == "Y" ]]; then
66 upload_to_tx
67 fi
68
69 abinfo "No upload as required."
70
71 exit 0