#!/bin/bash

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

    echo "**********************************************************"
    echo "*  engauge_*.ts files have been prepared for 'git diff'  *"
    echo "**********************************************************"
}

function prepare_one {
    if [ -f engauge_$1.ts ]; then
	echo "Converting $1"

	sed 's\<translation type="unfinished"></translation>\<translation type="unfinished"/>\g' engauge_$1.ts >tmp
	mv tmp engauge_$1.ts

	# Download files expect &apos; instead of single quote
	sed "s/'/&apos;/g" engauge_$1.ts >tmp
	mv tmp engauge_$1.ts	
    else
	echo "Skipping $1"	
    fi
}

main
