#! /bin/sh

# Test multi-domain handling.

tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15

tmpfiles="$tmpfiles foo.po"
cat <<\EOF > foo.po
domain "foo-de"
msgid ""
msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"

# Das ist ein Kommentar.
msgid "hello"
msgstr "Hallo"

# Noch einer.
msgid "bye"
msgstr "Tsch"

domain "foo-fr"
msgid ""
msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"

# Ceci est un commentaire.
msgid "hello"
msgstr "Salut"

# Encore un.
msgid "bye"
msgstr "A bientt"
EOF

tmpfiles="$tmpfiles foo.pot"
cat <<EOF > foo.pot
msgid "Hello"
msgstr ""
EOF

tmpfiles="$tmpfiles foo.out"
: ${MSGMERGE=msgmerge}
${MSGMERGE} --multi-domain -q foo.po foo.pot -o foo.out
test $? = 0 || { rm -fr $tmpfiles; exit 1; }

tmpfiles="$tmpfiles foo.ok"
cat <<\EOF > foo.ok
domain "foo-de"

msgid ""
msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"

# Das ist ein Kommentar.
#, fuzzy
msgid "Hello"
msgstr "Hallo"

# Noch einer.
#~ msgid "bye"
#~ msgstr "Tsch"

domain "foo-fr"

msgid ""
msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"

# Ceci est un commentaire.
#, fuzzy
msgid "Hello"
msgstr "Salut"

# Encore un.
#~ msgid "bye"
#~ msgstr "A bientt"
EOF

: ${DIFF=diff}
${DIFF} foo.ok foo.out
result=$?

rm -fr $tmpfiles

exit $result
