1#! /bin/sh
2
3# Test 'I' format directive flag.
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles fc5.tmp fc5.pot"
9: ${XGETTEXT=xgettext}
10${XGETTEXT} -o fc5.tmp --omit-header --no-location ${top_srcdir}/tests/format-c-5-prg.c
11test $? = 0 || { rm -fr $tmpfiles; exit 1; }
12tr -d '\r' < fc5.tmp > fc5.pot
13test $? = 0 || { rm -fr $tmpfiles; exit 1; }
14
15tmpfiles="$tmpfiles fc5.ok"
16cat <<EOF > fc5.ok
17#, c-format
18msgid "father of %d children"
19msgstr ""
20EOF
21
22: ${DIFF=diff}
23${DIFF} fc5.ok fc5.pot || exit 1
24
25tmpfiles="$tmpfiles fa.po"
26# This should better be Farsi, not German. Can some translator help me?
27cat <<EOF > fa.po
28#, c-format
29msgid "father of %d children"
30msgstr "Vater von %Id Kindern"
31EOF
32
33tmpfiles="$tmpfiles fa"
34test -d fa || mkdir fa
35test -d fa/LC_MESSAGES || mkdir fa/LC_MESSAGES
36
37: ${MSGFMT=msgfmt}
38${MSGFMT} -o fa/LC_MESSAGES/fc5.mo fa.po
39
40tmpfiles="$tmpfiles fa.po.tmp fa.po.un"
41: ${MSGUNFMT=msgunfmt}
42${MSGUNFMT} -o fa.po.tmp fa/LC_MESSAGES/fc5.mo
43test $? = 0 || { rm -fr $tmpfiles; exit 1; }
44tr -d '\r' < fa.po.tmp > fa.po.un
45test $? = 0 || { rm -fr $tmpfiles; exit 1; }
46
47: ${DIFF=diff}
48${DIFF} fa.po fa.po.un || exit 1
49
50LANGUAGE= ./fc5 fa_IR
51case $? in
52  0) ;;
53  77)
54    if test -f /usr/bin/localedef; then
55      echo "Skipping test: locale fa_IR not installed"
56    else
57      echo "Skipping test: locale fa_IR not supported"
58    fi
59    rm -fr $tmpfiles; exit 77;;
60  *) exit 1;;
61esac
62
63rm -fr $tmpfiles
64
65exit 0
66