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