#!/bin/sh
#---------------------------------------------------------------
# Project         : Mandrake Linux
# Module          : spec-helper
# File            : fix-mo
# Version         : $Id$
# Author          : Pablo Saratxaga
# Created On      : Fri Feb 14 08:27:47 2003
# Purpose         : Fix bad translations
#---------------------------------------------------------------

if [ -z "$RPM_BUILD_ROOT" ]; then
    echo "No build root defined" >&2
    exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
    echo "Invalid build root" >&2
    exit 1
fi

# HP people wants to have 'Gnome' in ascii;
# so "׳" is converted to 'GNOME'

KO_MESSAGES="$RPM_BUILD_ROOT"/usr/share/locale/ko/LC_MESSAGES

TMP="$KO_MESSAGES/tmpfile"
TMP2="$KO_MESSAGES/tmpfile2"

ret=0

[ -f "$KO_MESSAGES/*.mo" ] || exit 0

for i in "$KO_MESSAGES"/*.mo ; do
    msgunfmt -o $TMP $i
    if grep -qi '^"Content-Type: text/plain; charset=euc-kr.n"$' $TMP; then
	sed 's:׳:GNOME:g' < $TMP > $TMP2 && msgfmt -o $i $TMP2
	ret=$?
    elif grep -qi '^"Content-Type: text/plain; charset=utf-8.n"$' $TMP; then
	sed 's:그놈:GNOME:g' < $TMP > $TMP2 && msgfmt -o $i $TMP2
	ret=$?
    else
	echo "Unsupported encoding" 1>&2
    fi
done

rm -f $TMP $TMP2

exit $ret

# fix-mo ends here
