• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ... 3.0.0 when an UTF-8 locale is
8# present, because fpk ignores the locale's encoding. It supports only unibyte
9# locales. This here is a quick workaround:
10UTF8_LOCALE_UNSUPPORTED=yes
11
12cat <<\EOF > pascalprog.pp
13program pascalprog;
14{$mode delphi}
15
16uses gettext, sysutils;
17
18resourcestring
19  question = '''Your command, please?'', asked the waiter.';
20  currencies = '%s is replaced by %s.';
21
22begin
23  translateresourcestrings('%s/LC_MESSAGES/pascalprog.mo');
24  writeln(question);
25  writeln(format(currencies, ['FF', 'EUR']));
26end.
27EOF
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# fpc 3.0.0 or newer produces a .rsj file instead of a .rst file.
38if test -f pascalprog.rsj; then
39  suffix=rsj
40else
41  suffix=rst
42fi
43${XGETTEXT} -o pascalprog.tmp --omit-header --add-location pascalprog.${suffix} || Exit 1
44LC_ALL=C tr -d '\r' < pascalprog.tmp > pascalprog.pot || Exit 1
45
46cat <<EOF > pascalprog.ok
47#: pascalprog.question
48msgid "'Your command, please?', asked the waiter."
49msgstr ""
50
51#: pascalprog.currencies
52#, object-pascal-format
53msgid "%s is replaced by %s."
54msgstr ""
55EOF
56
57: ${DIFF=diff}
58${DIFF} pascalprog.ok pascalprog.pot || Exit 1
59
60cat <<\EOF > fr.po
61msgid ""
62msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
63
64#: pascalprog.question
65msgid "'Your command, please?', asked the waiter."
66msgstr "�Votre commande, s'il vous plait�, dit le gar�on."
67
68# Reverse the arguments.
69#: pascalprog.currencies
70#, object-pascal-format
71msgid "%s is replaced by %s."
72msgstr "%1:s remplace %0:s."
73EOF
74
75: ${MSGMERGE=msgmerge}
76${MSGMERGE} -q -o fr.po.tmp fr.po pascalprog.pot || Exit 1
77LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || Exit 1
78
79: ${DIFF=diff}
80${DIFF} fr.po fr.po.new || Exit 1
81
82test -d fr || mkdir fr
83test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
84
85: ${MSGFMT=msgfmt}
86${MSGFMT} -o fr/LC_MESSAGES/pascalprog.mo fr.po
87
88: ${DIFF=diff}
89cat <<\EOF > pascalprog.ok
90Votre commande, s'il vous plait�, dit le gar�on.
91EUR remplace FF.
92EOF
93cat <<\EOF > pascalprog.oku
94«Votre commande, s'il vous plait», dit le garçon.
95EUR remplace FF.
96EOF
97
98: ${LOCALE_FR=fr_FR}
99: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
100if test $LOCALE_FR != none; then
101  prepare_locale_ fr $LOCALE_FR
102  LANGUAGE= LC_ALL= LC_MESSAGES= LC_CTYPE= LANG=$LOCALE_FR ./pascalprog > pascalprog.out || Exit 1
103  : ${DIFF=diff}
104  ${DIFF} pascalprog.ok pascalprog.out || Exit 1
105fi
106if test -z "$UTF8_LOCALE_UNSUPPORTED"; then
107  if test $LOCALE_FR_UTF8 != none; then
108    prepare_locale_ fr $LOCALE_FR_UTF8
109    LANGUAGE= LC_ALL= LC_MESSAGES= LC_CTYPE= LANG=$LOCALE_FR_UTF8 ./pascalprog > pascalprog.out || Exit 1
110    : ${DIFF=diff}
111    ${DIFF} pascalprog.oku pascalprog.out || Exit 1
112  fi
113  if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
114    if test -f /usr/bin/localedef; then
115      echo "Skipping test: no french locale is installed"
116    else
117      echo "Skipping test: no french locale is supported"
118    fi
119    Exit 77
120  fi
121else
122  if test $LOCALE_FR = none; then
123    if test -f /usr/bin/localedef; then
124      echo "Skipping test: no traditional french locale is installed"
125    else
126      echo "Skipping test: no traditional french locale is supported"
127    fi
128    Exit 77
129  fi
130fi
131
132Exit 0
133