1*946379e7Schristos#! /bin/sh 2*946379e7Schristos 3*946379e7Schristos# Test of gettext facilities in the Objective C language. 4*946379e7Schristos# Assumes an fr_FR locale is installed. 5*946379e7Schristos# Assumes the following packages are installed: gcc. 6*946379e7Schristos 7*946379e7Schristostmpfiles="" 8*946379e7Schristostrap 'rm -fr $tmpfiles' 1 2 3 15 9*946379e7Schristos 10*946379e7Schristos# Test whether an ObjectiveC compiler is found. 11*946379e7Schristostmpfiles="$tmpfiles hello.m hello.${OBJEXT} hello${EXEEXT}" 12*946379e7Schristoscat <<\EOF > hello.m 13*946379e7Schristos#include <stdio.h> 14*946379e7Schristos#include <stdlib.h> 15*946379e7Schristosint main () 16*946379e7Schristos{ 17*946379e7Schristos printf ("Hello world\n"); 18*946379e7Schristos exit (0); 19*946379e7Schristos} 20*946379e7SchristosEOF 21*946379e7Schristos${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o hello hello.m 2>/dev/null \ 22*946379e7Schristos || { echo "Skipping test: Objective C compiler not found" 23*946379e7Schristos rm -fr $tmpfiles; exit 77 24*946379e7Schristos } 25*946379e7Schristos 26*946379e7Schristostmpfiles="$tmpfiles prog.m" 27*946379e7Schristoscat <<\EOF > prog.m 28*946379e7Schristos#include "config.h" 29*946379e7Schristos#include <libintl.h> 30*946379e7Schristos#include <locale.h> 31*946379e7Schristos#include <stdio.h> 32*946379e7Schristos#include <stdlib.h> 33*946379e7Schristos#include "xsetenv.h" 34*946379e7Schristos#define _(string) gettext (string) 35*946379e7Schristos 36*946379e7Schristosint main (int argc, char *argv[]) 37*946379e7Schristos{ 38*946379e7Schristos int n = atoi (argv[2]); 39*946379e7Schristos 40*946379e7Schristos xsetenv ("LC_ALL", argv[1], 1); 41*946379e7Schristos if (setlocale (LC_ALL, "") == NULL) 42*946379e7Schristos /* Couldn't set locale. */ 43*946379e7Schristos exit (77); 44*946379e7Schristos 45*946379e7Schristos textdomain ("prog"); 46*946379e7Schristos bindtextdomain ("prog", "."); 47*946379e7Schristos 48*946379e7Schristos printf (_("'Your command, please?', asked the waiter.")); 49*946379e7Schristos printf ("\n"); 50*946379e7Schristos 51*946379e7Schristos printf (ngettext ("a piece of cake", "%d pieces of cake", n), n); 52*946379e7Schristos printf ("\n"); 53*946379e7Schristos 54*946379e7Schristos printf (_("%s is replaced by %s."), "FF", "EUR"); 55*946379e7Schristos printf ("\n"); 56*946379e7Schristos 57*946379e7Schristos exit (0); 58*946379e7Schristos} 59*946379e7SchristosEOF 60*946379e7Schristos 61*946379e7Schristos# Variable needed by LTLIBINTL. 62*946379e7Schristostop_builddir=.. 63*946379e7Schristos 64*946379e7Schristostmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}" 65*946379e7Schristos# Put the -I flags before ${CFLAGS} ${CPPFLAGS}, to make sure that libintl.h 66*946379e7Schristos# is found in the build directory, regardless of -I options present in 67*946379e7Schristos# ${CFLAGS} or ${CPPFLAGS}. 68*946379e7Schristos${LIBTOOL} --quiet --mode=link ${CC} -I.. -I$top_srcdir/gnulib-lib ../gnulib-lib/libgettextlib.la -I../intl ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.m ${LTLIBINTL} \ 69*946379e7Schristos || exit 1 70*946379e7Schristos 71*946379e7Schristostmpfiles="$tmpfiles prog.pot" 72*946379e7Schristos: ${XGETTEXT=xgettext} 73*946379e7Schristos${XGETTEXT} -o prog.pot --omit-header --no-location -k_ prog.m 74*946379e7Schristos 75*946379e7Schristostmpfiles="$tmpfiles prog.ok" 76*946379e7Schristoscat <<EOF > prog.ok 77*946379e7Schristos#, c-format 78*946379e7Schristosmsgid "'Your command, please?', asked the waiter." 79*946379e7Schristosmsgstr "" 80*946379e7Schristos 81*946379e7Schristos#, c-format 82*946379e7Schristosmsgid "a piece of cake" 83*946379e7Schristosmsgid_plural "%d pieces of cake" 84*946379e7Schristosmsgstr[0] "" 85*946379e7Schristosmsgstr[1] "" 86*946379e7Schristos 87*946379e7Schristos#, c-format 88*946379e7Schristosmsgid "%s is replaced by %s." 89*946379e7Schristosmsgstr "" 90*946379e7SchristosEOF 91*946379e7Schristos 92*946379e7Schristos: ${DIFF=diff} 93*946379e7Schristos${DIFF} prog.ok prog.pot || exit 1 94*946379e7Schristos 95*946379e7Schristostmpfiles="$tmpfiles fr.po" 96*946379e7Schristoscat <<\EOF > fr.po 97*946379e7Schristosmsgid "" 98*946379e7Schristosmsgstr "" 99*946379e7Schristos"Content-Type: text/plain; charset=ISO-8859-1\n" 100*946379e7Schristos"Plural-Forms: nplurals=2; plural=(n > 1);\n" 101*946379e7Schristos 102*946379e7Schristos#, c-format 103*946379e7Schristosmsgid "'Your command, please?', asked the waiter." 104*946379e7Schristosmsgstr "�Votre commande, s'il vous plait�, dit le gar�on." 105*946379e7Schristos 106*946379e7Schristos# Les gateaux allemands sont les meilleurs du monde. 107*946379e7Schristos#, c-format 108*946379e7Schristosmsgid "a piece of cake" 109*946379e7Schristosmsgid_plural "%d pieces of cake" 110*946379e7Schristosmsgstr[0] "un morceau de gateau" 111*946379e7Schristosmsgstr[1] "%d morceaux de gateau" 112*946379e7Schristos 113*946379e7Schristos# Reverse the arguments. 114*946379e7Schristos#, c-format 115*946379e7Schristosmsgid "%s is replaced by %s." 116*946379e7Schristosmsgstr "%2$s remplace %1$s." 117*946379e7SchristosEOF 118*946379e7Schristos 119*946379e7Schristostmpfiles="$tmpfiles fr.po.new" 120*946379e7Schristos: ${MSGMERGE=msgmerge} 121*946379e7Schristos${MSGMERGE} -q -o fr.po.new fr.po prog.pot 122*946379e7Schristos 123*946379e7Schristos: ${DIFF=diff} 124*946379e7Schristos${DIFF} fr.po fr.po.new || exit 1 125*946379e7Schristos 126*946379e7Schristostmpfiles="$tmpfiles fr" 127*946379e7Schristostest -d fr || mkdir fr 128*946379e7Schristostest -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES 129*946379e7Schristos 130*946379e7Schristos: ${MSGFMT=msgfmt} 131*946379e7Schristos${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po 132*946379e7Schristos 133*946379e7Schristostmpfiles="$tmpfiles prog.ok prog.oku prog.out" 134*946379e7Schristos: ${DIFF=diff} 135*946379e7Schristoscat <<\EOF > prog.ok 136*946379e7Schristos�Votre commande, s'il vous plait�, dit le gar�on. 137*946379e7Schristos2 morceaux de gateau 138*946379e7SchristosEUR remplace FF. 139*946379e7SchristosEOF 140*946379e7Schristoscat <<\EOF > prog.oku 141*946379e7Schristos«Votre commande, s'il vous plait», dit le garçon. 142*946379e7Schristos2 morceaux de gateau 143*946379e7SchristosEUR remplace FF. 144*946379e7SchristosEOF 145*946379e7Schristos 146*946379e7Schristos: ${LOCALE_FR=fr_FR} 147*946379e7Schristos: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 148*946379e7Schristosif test $LOCALE_FR != none; then 149*946379e7Schristos LANGUAGE= ./prog $LOCALE_FR 2 > prog.out 150*946379e7Schristos case $? in 151*946379e7Schristos 0) ${DIFF} prog.ok prog.out || exit 1;; 152*946379e7Schristos 77) LOCALE_FR=none;; 153*946379e7Schristos *) exit 1;; 154*946379e7Schristos esac 155*946379e7Schristosfi 156*946379e7Schristosif test $LOCALE_FR_UTF8 != none; then 157*946379e7Schristos LANGUAGE= ./prog $LOCALE_FR_UTF8 2 > prog.out 158*946379e7Schristos case $? in 159*946379e7Schristos 0) ${DIFF} prog.oku prog.out || exit 1;; 160*946379e7Schristos 77) LOCALE_FR_UTF8=none;; 161*946379e7Schristos *) exit 1;; 162*946379e7Schristos esac 163*946379e7Schristosfi 164*946379e7Schristosif test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then 165*946379e7Schristos if test -f /usr/bin/localedef; then 166*946379e7Schristos echo "Skipping test: no french locale is installed" 167*946379e7Schristos else 168*946379e7Schristos echo "Skipping test: no french locale is supported" 169*946379e7Schristos fi 170*946379e7Schristos rm -fr $tmpfiles; exit 77 171*946379e7Schristosfi 172*946379e7Schristos 173*946379e7Schristosrm -fr $tmpfiles 174*946379e7Schristos 175*946379e7Schristosexit 0 176