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