3 # Test of gettext facilities in the Object Pascal language.
4 # Assumes the following packages are installed: fpk.
6 # Note: This test fails with fpk 1.0.10 when an UTF-8 locale is present,
7 # because fpk ignores the locale's encoding. It supports only unibyte locales.
8 # This here is a quick workaround:
9 UTF8_LOCALE_UNSUPPORTED=yes
12 trap 'rm -fr $tmpfiles' 1 2 3 15
14 tmpfiles="$tmpfiles pascalprog.pp"
15 cat <<\EOF > pascalprog.pp
19 uses gettext, sysutils;
22 question = '''Your command, please?'', asked the waiter.';
23 currencies = '%s is replaced by %s.';
26 translateresourcestrings('l-pascal/%s/LC_MESSAGES/pascalprog.mo');
28 writeln(format(currencies, ['FF', 'EUR']));
32 tmpfiles="$tmpfiles pascalprog.o pascalprog.rst pascalprog"
33 (ppc386 pascalprog.pp) >/dev/null 2>&1 ||
34 (ppcx64 pascalprog.pp) >/dev/null 2>&1 ||
36 echo "Skipping test: Pascal compiler ppc386 or ppcx64 not found"
37 rm -fr $tmpfiles; exit 77
40 tmpfiles="$tmpfiles l-pascal-pascalprog.tmp l-pascal-pascalprog.pot"
41 : ${XGETTEXT=xgettext}
42 ${XGETTEXT} -o l-pascal-pascalprog.tmp --omit-header --add-location pascalprog.rst
43 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
44 LC_ALL=C tr -d '\r' < l-pascal-pascalprog.tmp > l-pascal-pascalprog.pot
45 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
47 tmpfiles="$tmpfiles l-pascal-pascalprog.ok"
48 cat <<EOF > l-pascal-pascalprog.ok
49 #: pascalprog.question
50 msgid "'Your command, please?', asked the waiter."
53 #: pascalprog.currencies
54 #, object-pascal-format
55 msgid "%s is replaced by %s."
60 ${DIFF} l-pascal-pascalprog.ok l-pascal-pascalprog.pot || exit 1
62 tmpfiles="$tmpfiles l-pascal-fr.po"
63 cat <<\EOF > l-pascal-fr.po
65 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
67 #: pascalprog.question
68 msgid "'Your command, please?', asked the waiter."
69 msgstr "«Votre commande, s'il vous plait», dit le garçon."
71 # Reverse the arguments.
72 #: pascalprog.currencies
73 #, object-pascal-format
74 msgid "%s is replaced by %s."
75 msgstr "%1:s remplace %0:s."
78 tmpfiles="$tmpfiles l-pascal-fr.po.tmp l-pascal-fr.po.new"
79 : ${MSGMERGE=msgmerge}
80 ${MSGMERGE} -q -o l-pascal-fr.po.tmp l-pascal-fr.po l-pascal-pascalprog.pot
81 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
82 LC_ALL=C tr -d '\r' < l-pascal-fr.po.tmp > l-pascal-fr.po.new
83 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
86 ${DIFF} l-pascal-fr.po l-pascal-fr.po.new || exit 1
88 tmpfiles="$tmpfiles l-pascal"
89 test -d l-pascal || mkdir l-pascal
90 test -d l-pascal/fr || mkdir l-pascal/fr
91 test -d l-pascal/fr/LC_MESSAGES || mkdir l-pascal/fr/LC_MESSAGES
94 ${MSGFMT} -o l-pascal/fr/LC_MESSAGES/pascalprog.mo l-pascal-fr.po
96 tmpfiles="$tmpfiles l-pascal-pascalprog.ok l-pascal-pascalprog.oku l-pascal-pascalprog.out"
98 cat <<\EOF > l-pascal-pascalprog.ok
99 «Votre commande, s'il vous plait», dit le garçon.
102 cat <<\EOF > l-pascal-pascalprog.oku
103 «Votre commande, s'il vous plait», dit le garçon.
108 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
109 if test $LOCALE_FR != none; then
110 LANGUAGE= LC_ALL= LC_MESSAGES= LC_CTYPE= LANG=$LOCALE_FR ./pascalprog > l-pascal-pascalprog.out || exit 1
112 ${DIFF} l-pascal-pascalprog.ok l-pascal-pascalprog.out || exit 1
114 if test -z "$UTF8_LOCALE_UNSUPPORTED"; then
115 if test $LOCALE_FR_UTF8 != none; then
116 LANGUAGE= LC_ALL= LC_MESSAGES= LC_CTYPE= LANG=$LOCALE_FR_UTF8 ./pascalprog > l-pascal-pascalprog.out || exit 1
118 ${DIFF} l-pascal-pascalprog.oku l-pascal-pascalprog.out || exit 1
120 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
121 if test -f /usr/bin/localedef; then
122 echo "Skipping test: no french locale is installed"
124 echo "Skipping test: no french locale is supported"
126 rm -fr $tmpfiles; exit 77
129 if test $LOCALE_FR = none; then
130 if test -f /usr/bin/localedef; then
131 echo "Skipping test: no traditional french locale is installed"
133 echo "Skipping test: no traditional french locale is supported"
135 rm -fr $tmpfiles; exit 77