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