#!/bin/sh

if [ "$#" != 1 ]; then
	cat << HERE
Usage: 'make-mo <LANG>'
Eg:    'make-mo fr' to compile the French translation, fr.po, ready for use.
HERE
	exit 1
fi

OUT_DIR=../../Messages
LOCALE_DIR="$OUT_DIR/$1/LC_MESSAGES"
OUT="$LOCALE_DIR/ROX-Filer.mo"
mkdir -p "$LOCALE_DIR"

# This code converts to UTF-8 format. Needed by Gtk+-2.0 at
# least, and may help with other versions.
charset=`grep "charset=" $1.po | head -1 | sed 's/^.*charset=\(.*\)\\\n.*/\1/'`
echo Using charset \'$charset\'
iconv -f $charset -t utf-8 $1.po | \
	sed 's/; charset=\(.*\)\\n"/; charset=utf-8\\n"/' | \
	msgfmt --statistics - -o $OUT && echo Created file $OUT OK
