Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / lang-pascal
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test of gettext facilities in the Object Pascal language.
5 # Assumes the following packages are installed: fpk.
6
7 # Note: This test fails with fpk 1.0.10 when an UTF-8 locale is present,
8 # because fpk ignores the locale's encoding. It supports only unibyte locales.
9 # This here is a quick workaround:
10 UTF8_LOCALE_UNSUPPORTED=yes
11
12 cat <<\EOF > pascalprog.pp
13 program pascalprog;
14 {$mode delphi}
15
16 uses gettext, sysutils;
17
18 resourcestring
19   question = '''Your command, please?'', asked the waiter.';
20   currencies = '%s is replaced by %s.';
21
22 begin
23   translateresourcestrings('%s/LC_MESSAGES/pascalprog.mo');
24   writeln(question);
25   writeln(format(currencies, ['FF', 'EUR']));
26 end.
27 EOF
28
29 (ppc386 pascalprog.pp) >/dev/null 2>&1 ||
30 (ppcx64 pascalprog.pp) >/dev/null 2>&1 ||
31 {
32   echo "Skipping test: Pascal compiler ppc386 or ppcx64 not found"
33   exit 77
34 }
35
36 : ${XGETTEXT=xgettext}
37 ${XGETTEXT} -o pascalprog.tmp --omit-header --add-location pascalprog.rst || exit 1
38 LC_ALL=C tr -d '\r' < pascalprog.tmp > pascalprog.pot || exit 1
39
40 cat <<EOF > pascalprog.ok
41 #: pascalprog.question
42 msgid "'Your command, please?', asked the waiter."
43 msgstr ""
44
45 #: pascalprog.currencies
46 #, object-pascal-format
47 msgid "%s is replaced by %s."
48 msgstr ""
49 EOF
50
51 : ${DIFF=diff}
52 ${DIFF} pascalprog.ok pascalprog.pot || exit 1
53
54 cat <<\EOF > fr.po
55 msgid ""
56 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
57
58 #: pascalprog.question
59 msgid "'Your command, please?', asked the waiter."
60 msgstr "«Votre commande, s'il vous plait», dit le garçon."
61
62 # Reverse the arguments.
63 #: pascalprog.currencies
64 #, object-pascal-format
65 msgid "%s is replaced by %s."
66 msgstr "%1:s remplace %0:s."
67 EOF
68
69 : ${MSGMERGE=msgmerge}
70 ${MSGMERGE} -q -o fr.po.tmp fr.po pascalprog.pot || exit 1
71 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
72
73 : ${DIFF=diff}
74 ${DIFF} fr.po fr.po.new || exit 1
75
76 test -d fr || mkdir fr
77 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
78
79 : ${MSGFMT=msgfmt}
80 ${MSGFMT} -o fr/LC_MESSAGES/pascalprog.mo fr.po
81
82 : ${DIFF=diff}
83 cat <<\EOF > pascalprog.ok
84 «Votre commande, s'il vous plait», dit le garçon.
85 EUR remplace FF.
86 EOF
87 cat <<\EOF > pascalprog.oku
88 «Votre commande, s'il vous plait», dit le garçon.
89 EUR remplace FF.
90 EOF
91
92 : ${LOCALE_FR=fr_FR}
93 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
94 if test $LOCALE_FR != none; then
95   prepare_locale_ fr $LOCALE_FR
96   LANGUAGE= LC_ALL= LC_MESSAGES= LC_CTYPE= LANG=$LOCALE_FR ./pascalprog > pascalprog.out || exit 1
97   : ${DIFF=diff}
98   ${DIFF} pascalprog.ok pascalprog.out || exit 1
99 fi
100 if test -z "$UTF8_LOCALE_UNSUPPORTED"; then
101   if test $LOCALE_FR_UTF8 != none; then
102     prepare_locale_ fr $LOCALE_FR_UTF8
103     LANGUAGE= LC_ALL= LC_MESSAGES= LC_CTYPE= LANG=$LOCALE_FR_UTF8 ./pascalprog > pascalprog.out || exit 1
104     : ${DIFF=diff}
105     ${DIFF} pascalprog.oku pascalprog.out || exit 1
106   fi
107   if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
108     if test -f /usr/bin/localedef; then
109       echo "Skipping test: no french locale is installed"
110     else
111       echo "Skipping test: no french locale is supported"
112     fi
113     exit 77
114   fi
115 else
116   if test $LOCALE_FR = none; then
117     if test -f /usr/bin/localedef; then
118       echo "Skipping test: no traditional french locale is installed"
119     else
120       echo "Skipping test: no traditional french locale is supported"
121     fi
122     exit 77
123   fi
124 fi
125
126 exit 0