Home | History | Annotate | Line # | Download | only in tests
      1 #! /bin/sh
      2 
      3 # Test C support: extraction of contexts, disambiguating according to the
      4 # argument count.
      5 
      6 tmpfiles=""
      7 trap 'rm -fr $tmpfiles' 1 2 3 15
      8 
      9 tmpfiles="$tmpfiles xg-c-11.c"
     10 cat <<\EOF > xg-c-11.c
     11 // (KDE) The 1-argument i18n macro is a simple gettext without context.
     12 print (i18n ("help"));
     13 // (KDE) The 2-argument i18n macro has the context first.
     14 print (i18n ("Help", "about"));
     15 // (KDE) The 3-argument i18n macro is an ngettext without context.
     16 print (i18n ("error", "errors", 7));
     17 EOF
     18 
     19 tmpfiles="$tmpfiles xg-c-11.po"
     20 : ${XGETTEXT=xgettext}
     21 ${XGETTEXT} --omit-header --no-location \
     22   --keyword=i18n:1 --keyword=i18n:1c,2,2t --keyword=i18n:1,2,3t \
     23   -d xg-c-11 xg-c-11.c
     24 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
     25 
     26 tmpfiles="$tmpfiles xg-c-11.ok"
     27 cat <<EOF > xg-c-11.ok
     28 msgid "help"
     29 msgstr ""
     30 
     31 msgctxt "Help"
     32 msgid "about"
     33 msgstr ""
     34 
     35 msgid "error"
     36 msgid_plural "errors"
     37 msgstr[0] ""
     38 msgstr[1] ""
     39 EOF
     40 
     41 : ${DIFF=diff}
     42 ${DIFF} xg-c-11.ok xg-c-11.po
     43 result=$?
     44 
     45 rm -fr $tmpfiles
     46 
     47 exit $result
     48