Skip to content
Permalink
Browse files

update i18n and add i18n maint script

  • Loading branch information...
liushuyu committed Dec 30, 2017
1 parent a3d72de commit 96c5f05120ecff5694ce581bd71c71991e9ee43e
Showing with 3,584 additions and 810 deletions.
  1. +71 −0 buildtools/update_locales
  2. +3,513 −810 data/locale/en.ts
@@ -0,0 +1,71 @@
#!/bin/bash
aberr(){ printf "[\e[31mERROR\e[0m]: \e[1m%s\e[0m\n" "$*" >&2; }
abinfo(){ printf "[\e[96mINFO\e[0m]: \e[1m%s\e[0m\n" "$*" >&2; }

function upload_to_tx() {
if ! which tx > /dev/null; then
aberr "You don't have Transifex client installed. \n Run \`pip install transifex-client\` to install it."
exit 1
fi
abinfo "Uploading to transifex..."
if ! tx push -s; then
aberr "Problems occurred when uploading strings to Transifex."
printf "\t Either there are syntax errors in source file or you don't have permission to update the source file."
exit 1
fi
exit 0
}

function validate() {
ERR_LANG=""
ERR_BUF=""
for i in data/locale/*.ts; do
if ! ERR_BUF=$(lconvert-qt5 -i "${i}" -o "/tmp/test.qm" -of qm 2>&1); then
ERR_LANG+="\e[96m$(basename "${i}")\e[0m: \e[93m${ERR_BUF}\e[0m "
printf "\e[31mx\e[0m"
continue
fi
printf "\e[32m.\e[0m"
done
echo ""
if [[ "x${ERR_LANG}" != "x" ]]; then
aberr "The following files failed the validation: "
echo -e "${ERR_LANG}"
fi
}

abinfo "Checking for your environment..."
if ! which lupdate-qt5 > /dev/null; then
aberr "You don't seem to have Qt i18n tools installed."
printf "\tUsually this comes with your Qt installation, or you need to\n"
printf "\tinstall extra packages like \`qt5-tools\` or similar.\n"
exit 1;
fi

abinfo "Scanning directories..."

if test -d src/3rdparty/qt5-x11embed/3rdparty/ECM/; then
# prevent from collecting strings in ECM
rm -rf src/3rdparty/qt5-x11embed/3rdparty/ECM/
fi

if ! lupdate-qt5 -I include/ src/ plugins/ -ts data/locale/en.ts; then
aberr "There are some problems when collecting the strings."
exit 1
fi

abinfo "Validating translations..."
validate

abinfo "Translations successfully updated."
printf "Do you want to upload translations to Transifex? [y/N]: "
read -n 1 -r TX
echo ""

if [[ "$TX" == "y" || "$TX" == "Y" ]]; then
upload_to_tx
fi

abinfo "No upload as required."

exit 0
Oops, something went wrong.

0 comments on commit 96c5f05

Please sign in to comment.
You can’t perform that action at this time.