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