xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/tests/lang-librep (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1#! /bin/sh
2
3# Test of gettext facilities in the librep language.
4# Assumes an fr_FR locale is installed.
5# Assumes the following packages are installed: librep.
6
7tmpfiles=""
8trap 'rm -fr $tmpfiles' 1 2 3 15
9
10tmpfiles="$tmpfiles prog.jl"
11cat <<\EOF > prog.jl
12(require 'rep.i18n.gettext)
13
14(textdomain "prog")
15(bindtextdomain "prog" ".")
16
17(format standard-output "%s\n" (_ "'Your command, please?', asked the waiter."))
18
19(format standard-output "%s\n"
20        (format nil (_ "%s is replaced by %s.") "FF" "EUR"))
21EOF
22
23tmpfiles="$tmpfiles prog.pot"
24: ${XGETTEXT=xgettext}
25${XGETTEXT} -o prog.pot --omit-header --no-location prog.jl
26
27tmpfiles="$tmpfiles prog.ok"
28cat <<EOF > prog.ok
29msgid "'Your command, please?', asked the waiter."
30msgstr ""
31
32#, librep-format
33msgid "%s is replaced by %s."
34msgstr ""
35EOF
36
37: ${DIFF=diff}
38${DIFF} prog.ok prog.pot || exit 1
39
40tmpfiles="$tmpfiles fr.po"
41cat <<\EOF > fr.po
42msgid ""
43msgstr ""
44"Content-Type: text/plain; charset=ISO-8859-1\n"
45"Plural-Forms: nplurals=2; plural=(n > 1);\n"
46
47msgid "'Your command, please?', asked the waiter."
48msgstr "�Votre commande, s'il vous plait�, dit le garon."
49
50# Reverse the arguments.
51#, librep-format
52msgid "%s is replaced by %s."
53msgstr "%2$s remplace %1$s."
54EOF
55
56tmpfiles="$tmpfiles fr.po.new"
57: ${MSGMERGE=msgmerge}
58${MSGMERGE} -q -o fr.po.new fr.po prog.pot
59
60: ${DIFF=diff}
61${DIFF} fr.po fr.po.new || exit 1
62
63tmpfiles="$tmpfiles fr"
64test -d fr || mkdir fr
65test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
66
67: ${MSGFMT=msgfmt}
68${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
69
70# Test for presence of rep version 0.15.3 or newer.
71(rep --version) >/dev/null 2>/dev/null \
72  || { echo "Skipping test: rep not found"; rm -fr $tmpfiles; exit 77; }
73case `rep --version | sed -e 's/^[^0-9]*//'` in
74  0.[0-9] | 0.1[0-5] | 0.[0-9].* | 0.1[0-4].* | 0.15.[0-2] )
75    echo "Skipping test: rep version too old"; rm -fr $tmpfiles; exit 77;;
76esac
77
78# Test which of the fr_FR locales are installed.
79: ${LOCALE_FR=fr_FR}
80: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
81if test $LOCALE_FR != none; then
82  LC_ALL=$LOCALE_FR ./testlocale
83  case $? in
84    0) ;;
85    77) LOCALE_FR=none;;
86    *) exit 1;;
87  esac
88fi
89if test $LOCALE_FR_UTF8 != none; then
90  LC_ALL=$LOCALE_FR_UTF8 ./testlocale
91  case $? in
92    0) ;;
93    77) LOCALE_FR_UTF8=none;;
94    *) exit 1;;
95  esac
96fi
97if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
98  if test -f /usr/bin/localedef; then
99    echo "Skipping test: no french locale is installed"
100  else
101    echo "Skipping test: no french locale is supported"
102  fi
103  rm -fr $tmpfiles; exit 77
104fi
105
106tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
107: ${DIFF=diff}
108cat <<\EOF > prog.ok
109�Votre commande, s'il vous plait�, dit le gar�on.
110EUR remplace FF.
111EOF
112cat <<\EOF > prog.oku
113«Votre commande, s'il vous plait», dit le garçon.
114EUR remplace FF.
115EOF
116
117: ${LOCALE_FR=fr_FR}
118: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
119if test $LOCALE_FR != none; then
120  LANGUAGE= LC_ALL=$LOCALE_FR rep --no-rc --batch prog.jl > prog.out || exit 1
121  ${DIFF} prog.ok prog.out || exit 1
122fi
123if test $LOCALE_FR_UTF8 != none; then
124  LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 rep --no-rc --batch prog.jl > prog.out || exit 1
125  ${DIFF} prog.oku prog.out || exit 1
126fi
127
128rm -fr $tmpfiles
129
130exit 0
131