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: 9UTF8_LOCALE_UNSUPPORTED=yes 10 11tmpfiles="" 12trap 'rm -fr $tmpfiles' 1 2 3 15 13 14tmpfiles="$tmpfiles prog.pp" 15cat <<\EOF > prog.pp 16program prog; 17{$mode delphi} 18 19uses gettext, sysutils; 20 21resourcestring 22 question = '''Your command, please?'', asked the waiter.'; 23 currencies = '%s is replaced by %s.'; 24 25begin 26 translateresourcestrings('%s/LC_MESSAGES/prog.mo'); 27 writeln(question); 28 writeln(format(currencies, ['FF', 'EUR'])); 29end. 30EOF 31 32tmpfiles="$tmpfiles prog.o prog.rst prog" 33(ppc386 prog.pp) >/dev/null 2>&1 || { 34 echo "Skipping test: ppc386 compiler not found" 35 rm -fr $tmpfiles; exit 77 36} 37 38tmpfiles="$tmpfiles prog.pot" 39: ${XGETTEXT=xgettext} 40${XGETTEXT} -o prog.pot --omit-header --add-location prog.rst 41 42tmpfiles="$tmpfiles prog.ok" 43cat <<EOF > prog.ok 44#: prog.question 45msgid "'Your command, please?', asked the waiter." 46msgstr "" 47 48#: prog.currencies 49#, object-pascal-format 50msgid "%s is replaced by %s." 51msgstr "" 52EOF 53 54: ${DIFF=diff} 55${DIFF} prog.ok prog.pot || exit 1 56 57tmpfiles="$tmpfiles fr.po" 58cat <<\EOF > fr.po 59msgid "" 60msgstr "Content-Type: text/plain; charset=ISO-8859-1\n" 61 62#: prog.question 63msgid "'Your command, please?', asked the waiter." 64msgstr "�Votre commande, s'il vous plait�, dit le gar�on." 65 66# Reverse the arguments. 67#: prog.currencies 68#, object-pascal-format 69msgid "%s is replaced by %s." 70msgstr "%1:s remplace %0:s." 71EOF 72 73tmpfiles="$tmpfiles fr.po.new" 74: ${MSGMERGE=msgmerge} 75${MSGMERGE} -q -o fr.po.new fr.po prog.pot 76 77: ${DIFF=diff} 78${DIFF} fr.po fr.po.new || exit 1 79 80tmpfiles="$tmpfiles fr" 81test -d fr || mkdir fr 82test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES 83 84: ${MSGFMT=msgfmt} 85${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po 86 87tmpfiles="$tmpfiles prog.ok prog.oku prog.out" 88: ${DIFF=diff} 89cat <<\EOF > prog.ok 90�Votre commande, s'il vous plait�, dit le gar�on. 91EUR remplace FF. 92EOF 93cat <<\EOF > prog.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 LANGUAGE= LC_ALL= LC_MESSAGES= LC_CTYPE= LANG=$LOCALE_FR ./prog > prog.out || exit 1 102 : ${DIFF=diff} 103 ${DIFF} prog.ok prog.out || exit 1 104fi 105if test -z "$UTF8_LOCALE_UNSUPPORTED"; then 106 if test $LOCALE_FR_UTF8 != none; then 107 LANGUAGE= LC_ALL= LC_MESSAGES= LC_CTYPE= LANG=$LOCALE_FR_UTF8 ./prog > prog.out || exit 1 108 : ${DIFF=diff} 109 ${DIFF} prog.oku prog.out || exit 1 110 fi 111 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then 112 if test -f /usr/bin/localedef; then 113 echo "Skipping test: no french locale is installed" 114 else 115 echo "Skipping test: no french locale is supported" 116 fi 117 rm -fr $tmpfiles; exit 77 118 fi 119else 120 if test $LOCALE_FR = none; then 121 if test -f /usr/bin/localedef; then 122 echo "Skipping test: no traditional french locale is installed" 123 else 124 echo "Skipping test: no traditional french locale is supported" 125 fi 126 rm -fr $tmpfiles; exit 77 127 fi 128fi 129 130rm -fr $tmpfiles 131 132exit 0 133