Home | History | Annotate | Line # | Download | only in tests
      1  1.1  christos #! /bin/sh
      2  1.1  christos 
      3  1.1  christos # Test of gettext facilities in the PO/POT format.
      4  1.1  christos 
      5  1.1  christos tmpfiles=""
      6  1.1  christos trap 'rm -fr $tmpfiles' 1 2 3 15
      7  1.1  christos 
      8  1.1  christos # Test with POT format.
      9  1.1  christos 
     10  1.1  christos tmpfiles="$tmpfiles prog-in.pot"
     11  1.1  christos cat <<\EOF > prog-in.pot
     12  1.1  christos msgid "'Your command, please?', asked the waiter."
     13  1.1  christos msgstr ""
     14  1.1  christos 
     15  1.1  christos #, c-format
     16  1.1  christos msgid "a piece of cake"
     17  1.1  christos msgid_plural "%d pieces of cake"
     18  1.1  christos msgstr[0] ""
     19  1.1  christos msgstr[1] ""
     20  1.1  christos 
     21  1.1  christos #, c-format
     22  1.1  christos msgid "%s is replaced by %s."
     23  1.1  christos msgstr ""
     24  1.1  christos EOF
     25  1.1  christos 
     26  1.1  christos tmpfiles="$tmpfiles prog.pot"
     27  1.1  christos : ${XGETTEXT=xgettext}
     28  1.1  christos ${XGETTEXT} -o prog.pot --omit-header --add-location prog-in.pot
     29  1.1  christos 
     30  1.1  christos : ${DIFF=diff}
     31  1.1  christos ${DIFF} prog-in.pot prog.pot || exit 1
     32  1.1  christos 
     33  1.1  christos # Test with PO format.
     34  1.1  christos 
     35  1.1  christos tmpfiles="$tmpfiles prog-in.po"
     36  1.1  christos cat <<\EOF > prog-in.po
     37  1.1  christos msgid ""
     38  1.1  christos msgstr ""
     39  1.1  christos "Content-Type: text/plain; charset=ISO-8859-1\n"
     40  1.1  christos "Plural-Forms: nplurals=2; plural=(n > 1);\n"
     41  1.1  christos 
     42  1.1  christos msgid "'Your command, please?', asked the waiter."
     43  1.1  christos msgstr "Votre commande, s'il vous plait, dit le garon."
     44  1.1  christos 
     45  1.1  christos # Les gateaux allemands sont les meilleurs du monde.
     46  1.1  christos #, c-format
     47  1.1  christos msgid "a piece of cake"
     48  1.1  christos msgid_plural "%d pieces of cake"
     49  1.1  christos msgstr[0] "un morceau de gateau"
     50  1.1  christos msgstr[1] "%d morceaux de gateau"
     51  1.1  christos 
     52  1.1  christos # Reverse the arguments.
     53  1.1  christos #, c-format
     54  1.1  christos msgid "%s is replaced by %s."
     55  1.1  christos msgstr "%2$s remplace %1$s."
     56  1.1  christos EOF
     57  1.1  christos 
     58  1.1  christos tmpfiles="$tmpfiles prog.po"
     59  1.1  christos : ${XGETTEXT=xgettext}
     60  1.1  christos ${XGETTEXT} -o prog.po --omit-header --add-location prog-in.po
     61  1.1  christos 
     62  1.1  christos : ${DIFF=diff}
     63  1.1  christos ${DIFF} prog-in.po prog.po || exit 1
     64  1.1  christos 
     65  1.1  christos rm -fr $tmpfiles
     66  1.1  christos 
     67  1.1  christos exit 0
     68