• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
8cat <<\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"))
18EOF
19
20: ${XGETTEXT=xgettext}
21${XGETTEXT} -o prog.tmp --omit-header --no-location prog.jl || Exit 1
22LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || Exit 1
23
24cat <<EOF > prog.ok
25msgid "'Your command, please?', asked the waiter."
26msgstr ""
27
28#, librep-format
29msgid "%s is replaced by %s."
30msgstr ""
31EOF
32
33: ${DIFF=diff}
34${DIFF} prog.ok prog.pot || Exit 1
35
36cat <<\EOF > fr.po
37msgid ""
38msgstr ""
39"Content-Type: text/plain; charset=ISO-8859-1\n"
40"Plural-Forms: nplurals=2; plural=(n > 1);\n"
41
42msgid "'Your command, please?', asked the waiter."
43msgstr "�Votre commande, s'il vous plait�, dit le garon."
44
45# Reverse the arguments.
46#, librep-format
47msgid "%s is replaced by %s."
48msgstr "%2$s remplace %1$s."
49EOF
50
51: ${MSGMERGE=msgmerge}
52${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || Exit 1
53LC_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
58test -d fr || mkdir fr
59test -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; }
67case `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;;
70esac
71
72# Test which of the fr_FR locales are installed.
73: ${LOCALE_FR=fr_FR}
74: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
75if 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
82fi
83if 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
90fi
91if 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
98fi
99
100: ${DIFF=diff}
101cat <<\EOF > prog.ok
102�Votre commande, s'il vous plait�, dit le gar�on.
103EUR remplace FF.
104EOF
105cat <<\EOF > prog.oku
106«Votre commande, s'il vous plait», dit le garçon.
107EUR remplace FF.
108EOF
109
110: ${LOCALE_FR=fr_FR}
111: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
112if 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
116fi
117if 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
121fi
122
123Exit 0
124