#!/bin/bash

# Guess the target application if we aren't supplied one
if [ $# == 1 ]; then
	targetapp=$1
else
	targetapp=$(basename $(pwd))
	echo "Guessing application name is \"${targetapp}\""
fi

share=share/$targetapp
desktop=share/applications/$targetapp.desktop
metainfo=share/metainfo/$targetapp.metainfo.xml
mimetype=share/mime/packages/$targetapp-mimetype.xml

cache="po/.intltool-merge-cache"
rm -f $cache

if [ -d po ]; then
	if [ -f  ${mimetype}.in ]; then
		intltool-merge --xml-style --cache $cache po ${mimetype}.in $mimetype
	fi
	if [ -f  ${metainfo}.in ]; then
		intltool-merge --xml-style --cache $cache po ${metainfo}.in $metainfo
	fi
	if [ -f  ${desktop}.in ]; then
		intltool-merge --desktop-style --cache $cache po ${desktop}.in $desktop
	fi
else
	echo "$0: No translation directory"
fi
