Imported Upstream version 0.18.3.2
[platform/upstream/gettext.git] / gettext-tools / tests / lang-pascal
1 #! /bin/sh
2
3 # Test of gettext facilities in the Object Pascal language.
4 # Assumes the following packages are installed: fpk.
5
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
10
11 tmpfiles=""
12 trap 'rm -fr $tmpfiles' 1 2 3 15
13
14 tmpfiles="$tmpfiles pascalprog.pp"
15 cat <<\EOF > pascalprog.pp
16 program pascalprog;
17 {$mode delphi}
18
19 uses gettext, sysutils;
20
21 resourcestring
22   question = '''Your command, please?'', asked the waiter.';
23   currencies = '%s is replaced by %s.';
24
25 begin
26   translateresourcestrings('l-pascal/%s/LC_MESSAGES/pascalprog.mo');
27   writeln(question);
28   writeln(format(currencies, ['FF', 'EUR']));
29 end.
30 EOF
31
32 tmpfiles="$tmpfiles pascalprog.o pascalprog.rst pascalprog"
33 (ppc386 pascalprog.pp) >/dev/null 2>&1 ||
34 (ppcx64 pascalprog.pp) >/dev/null 2>&1 ||
35 {
36   echo "Skipping test: Pascal compiler ppc386 or ppcx64 not found"
37   rm -fr $tmpfiles; exit 77
38 }
39
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; }
46
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."
51 msgstr ""
52
53 #: pascalprog.currencies
54 #, object-pascal-format
55 msgid "%s is replaced by %s."
56 msgstr ""
57 EOF
58
59 : ${DIFF=diff}
60 ${DIFF} l-pascal-pascalprog.ok l-pascal-pascalprog.pot || exit 1
61
62 tmpfiles="$tmpfiles l-pascal-fr.po"
63 cat <<\EOF > l-pascal-fr.po
64 msgid ""
65 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
66
67 #: pascalprog.question
68 msgid "'Your command, please?', asked the waiter."
69 msgstr "«Votre commande, s'il vous plait», dit le garçon."
70
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."
76 EOF
77
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; }
84
85 : ${DIFF=diff}
86 ${DIFF} l-pascal-fr.po l-pascal-fr.po.new || exit 1
87
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
92
93 : ${MSGFMT=msgfmt}
94 ${MSGFMT} -o l-pascal/fr/LC_MESSAGES/pascalprog.mo l-pascal-fr.po
95
96 tmpfiles="$tmpfiles l-pascal-pascalprog.ok l-pascal-pascalprog.oku l-pascal-pascalprog.out"
97 : ${DIFF=diff}
98 cat <<\EOF > l-pascal-pascalprog.ok
99 «Votre commande, s'il vous plait», dit le garçon.
100 EUR remplace FF.
101 EOF
102 cat <<\EOF > l-pascal-pascalprog.oku
103 «Votre commande, s'il vous plait», dit le garçon.
104 EUR remplace FF.
105 EOF
106
107 : ${LOCALE_FR=fr_FR}
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
111   : ${DIFF=diff}
112   ${DIFF} l-pascal-pascalprog.ok l-pascal-pascalprog.out || exit 1
113 fi
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
117     : ${DIFF=diff}
118     ${DIFF} l-pascal-pascalprog.oku l-pascal-pascalprog.out || exit 1
119   fi
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"
123     else
124       echo "Skipping test: no french locale is supported"
125     fi
126     rm -fr $tmpfiles; exit 77
127   fi
128 else
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"
132     else
133       echo "Skipping test: no traditional french locale is supported"
134     fi
135     rm -fr $tmpfiles; exit 77
136   fi
137 fi
138
139 rm -fr $tmpfiles
140
141 exit 0