#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test multi-domain handling.

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 bientôt"
EOF

: ${MSGFMT=msgfmt}
${MSGFMT} foo.po || Exit 1

: ${MSGUNFMT=msgunfmt}
${MSGUNFMT} -o foo-de.tmp foo-de.mo || Exit 1
LC_ALL=C tr -d '\r' < foo-de.tmp > foo-de.out || Exit 1
${MSGUNFMT} -o foo-fr.tmp foo-fr.mo || Exit 1
LC_ALL=C tr -d '\r' < foo-fr.tmp > foo-fr.out || Exit 1

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

msgid "bye"
msgstr "Tschüß"

msgid "hello"
msgstr "Hallo"
EOF

cat <<\EOF > foo-fr.ok
msgid ""
msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"

msgid "bye"
msgstr "A bientôt"

msgid "hello"
msgstr "Salut"
EOF

: ${DIFF=diff}
${DIFF} foo-de.ok foo-de.out && ${DIFF} foo-fr.ok foo-fr.out
result=$?

exit $result
