| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | aberrscip-shell shell shell-project 0.0.0 aberr().(){ printfscip-shell system . . printf. "[\e[31mERROR\e[0m]: \e[1m%s\e[0m\n" "$*" >&2; } |
| 3 | abinfoscip-shell shell shell-project 0.0.0 abinfo().(){ printfscip-shell system . . printf. "[\e[96mINFO\e[0m]: \e[1m%s\e[0m\n" "$*" >&2; } |
| 4 | |
| 5 | function upload_to_txscip-shell shell shell-project 0.0.0 upload_to_tx().() { |
| 6 | if ! whichscip-shell system . . which. tx > /dev/nullscip-shell filesystem . . `/dev/null`.; then |
| 7 | aberrscip-shell shell shell-project 0.0.0 aberr(). "You don't have Transifex client installed. \n Run \`pip install transifex-client\` to install it." |
| 8 | exit 1 |
| 9 | fi |
| 10 | abinfoscip-shell shell shell-project 0.0.0 abinfo(). "Uploading to transifex..." |
| 11 | if ! tx push -s; then |
| 12 | aberrscip-shell shell shell-project 0.0.0 aberr(). "Problems occurred when uploading strings to Transifex." |
| 13 | printfscip-shell system . . 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 validatescip-shell shell shell-project 0.0.0 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.qmscip-shell filesystem . . `/tmp/test.qm`." -of qm 2>&1); then |
| 24 | ERR_LANG+="\e[96m$(basenamescip-shell system . . basename. "${i}")\e[0m: \e[93m${ERR_BUF}\e[0m " |
| 25 | printfscip-shell system . . printf. "\e[31mx\e[0m" |
| 26 | continue |
| 27 | fi |
| 28 | printfscip-shell system . . printf. "\e[32m.\e[0m" |
| 29 | done |
| 30 | echoscip-shell system . . echo. "" |
| 31 | if [[ "x${ERR_LANG}" != "x" ]]; then |
| 32 | aberrscip-shell shell shell-project 0.0.0 aberr(). "The following files failed the validation: " |
| 33 | echoscip-shell system . . echo. -e "${ERR_LANG}" |
| 34 | fi |
| 35 | } |
| 36 | |
| 37 | abinfoscip-shell shell shell-project 0.0.0 abinfo(). "Checking for your environment..." |
| 38 | if ! whichscip-shell system . . which. lupdate-qt5 > /dev/nullscip-shell filesystem . . `/dev/null`.; then |
| 39 | aberrscip-shell shell shell-project 0.0.0 aberr(). "You don't seem to have Qt i18n tools installed." |
| 40 | printfscip-shell system . . printf. "\tUsually this comes with your Qt installation, or you need to\n" |
| 41 | printfscip-shell system . . printf. "\tinstall extra packages like \`qt5-tools\` or similar.\n" |
| 42 | exit 1; |
| 43 | fi |
| 44 | |
| 45 | abinfoscip-shell shell shell-project 0.0.0 abinfo(). "Scanning directories..." |
| 46 | |
| 47 | if testscip-shell system . . test. -d src/3rdparty/qt5-x11embed/3rdparty/ECM/; then |
| 48 | # prevent from collecting strings in ECM |
| 49 | rmscip-shell system . . 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 | aberrscip-shell shell shell-project 0.0.0 aberr(). "There are some problems when collecting the strings." |
| 54 | exit 1 |
| 55 | fi |
| 56 | |
| 57 | abinfoscip-shell shell shell-project 0.0.0 abinfo(). "Validating translations..." |
| 58 | validatescip-shell shell shell-project 0.0.0 validate(). |
| 59 | |
| 60 | abinfoscip-shell shell shell-project 0.0.0 abinfo(). "Translations successfully updated." |
| 61 | printfscip-shell system . . printf. "Do you want to upload translations to Transifex? [y/N]: " |
| 62 | read -n 1 -r TX |
| 63 | echoscip-shell system . . echo. "" |
| 64 | |
| 65 | if [[ "$TX" == "y" || "$TX" == "Y" ]]; then |
| 66 | upload_to_txscip-shell shell shell-project 0.0.0 upload_to_tx(). |
| 67 | fi |
| 68 | |
| 69 | abinfoscip-shell shell shell-project 0.0.0 abinfo(). "No upload as required." |
| 70 | |
| 71 | exit 0 |