#!/bin/bash

# Usage: Download every language translation from transifex. Either 'Download for translation' or
#        'Download for use', since either option produces the same file but with a different name
#        (which is handled below)

function main {
    languages=(ar cs de en es fa_IR fr hi it ja kk ko nb nl pt ru zh)
    for language in "${languages[@]}"
    do
        merge_one $language
    done

    echo "*********************************************************************"
    echo "*  Check the temp_??.ts files for new content AND old translations  *"
    echo "*********************************************************************"
}

function merge_one {
    if [ -f for_translation_engauge-digitizer_engauge_ents_$1.ts ]; then
	echo "Converting $1"
        ./merge.py "engauge_$1.ts" "for_translation_engauge-digitizer_engauge_ents_$1.ts" "temp_$1.ts"
    elif [ -f for_use_engauge-digitizer_engauge_ents_$1.ts ]; then
	echo "Converting $1"
        ./merge.py "engauge_$1.ts" "for_use_engauge-digitizer_engauge_ents_$1.ts" "temp_$1.ts"	
    else
	echo "Skipping $1"	
    fi
}

main
