#!/bin/bash

APPNAME="$(basename $(dirname $(pwd)))"

echodo() {
  echo "${@}"
  ${@}
}

# prepare transifex 
if [ ! -s  .tx/config ]; then
   mkdir -p .tx
   cat <<EOF > .tx/config
[main]
host = https://www.transifex.com

[o:anticapitalista:p:antix-development:r:$APPNAME]
file_filter = ./${APPNAME}_<lang>.ts
source_file = ${APPNAME}_en.ts
source_lang = en
type = ts
EOF
fi    

# remove existing translations
find . -type f -name '*.ts' -not -name '*.en.ts' -delete

# get all translations
if command -v tx >/dev/null; then
   echodo tx pull -r antix-development.$APPNAME  --all
fi

lupdate ../*.pro
