Home | History | Annotate | Line # | Download | only in tests
      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 prog.pp"
     15 cat <<\EOF > prog.pp
     16 program prog;
     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('%s/LC_MESSAGES/prog.mo');
     27   writeln(question);
     28   writeln(format(currencies, ['FF', 'EUR']));
     29 end.
     30 EOF
     31 
     32 tmpfiles="$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 
     38 tmpfiles="$tmpfiles prog.pot"
     39 : ${XGETTEXT=xgettext}
     40 ${XGETTEXT} -o prog.pot --omit-header --add-location prog.rst
     41 
     42 tmpfiles="$tmpfiles prog.ok"
     43 cat <<EOF > prog.ok
     44 #: prog.question
     45 msgid "'Your command, please?', asked the waiter."
     46 msgstr ""
     47 
     48 #: prog.currencies
     49 #, object-pascal-format
     50 msgid "%s is replaced by %s."
     51 msgstr ""
     52 EOF
     53 
     54 : ${DIFF=diff}
     55 ${DIFF} prog.ok prog.pot || exit 1
     56 
     57 tmpfiles="$tmpfiles fr.po"
     58 cat <<\EOF > fr.po
     59 msgid ""
     60 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
     61 
     62 #: prog.question
     63 msgid "'Your command, please?', asked the waiter."
     64 msgstr "Votre commande, s'il vous plait, dit le garon."
     65 
     66 # Reverse the arguments.
     67 #: prog.currencies
     68 #, object-pascal-format
     69 msgid "%s is replaced by %s."
     70 msgstr "%1:s remplace %0:s."
     71 EOF
     72 
     73 tmpfiles="$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 
     80 tmpfiles="$tmpfiles fr"
     81 test -d fr || mkdir fr
     82 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
     83 
     84 : ${MSGFMT=msgfmt}
     85 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
     86 
     87 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
     88 : ${DIFF=diff}
     89 cat <<\EOF > prog.ok
     90 Votre commande, s'il vous plait, dit le garon.
     91 EUR remplace FF.
     92 EOF
     93 cat <<\EOF > prog.oku
     94 Votre commande, s'il vous plait, dit le garon.
     95 EUR remplace FF.
     96 EOF
     97 
     98 : ${LOCALE_FR=fr_FR}
     99 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
    100 if 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
    104 fi
    105 if 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
    119 else
    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
    128 fi
    129 
    130 rm -fr $tmpfiles
    131 
    132 exit 0
    133