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