summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/lang-rst
blob: ce6a16e2c47cde6c327e5c8a140b081e3562cbf5 (plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#! /bin/sh

# Test of gettext facilities in the RST format.

tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15

tmpfiles="$tmpfiles prog.rst"
cat <<\EOF > prog.rst
# From the rstconv program itself.
rstconv.help='rstconv [-h|--help]    Displays this help'#10+
'rstconv options        Convert rst file'#10#10+
'Options are:'#10+
'  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)'#10+
'  -o file    Write output to specified file (REQUIRED)'#10+
'  -f format  Specifies the output format:'#10+
'             po    GNU gettext .po (portable) format (DEFAULT)'#10

rstconv.InvalidOption='Invalid option - '
rstconv.OptionAlreadySpecified='Option has already been specified - '
rstconv.NoOutFilename='No output filename specified'
rstconv.InvalidOutputFormat='Invalid output format -'
EOF

tmpfiles="$tmpfiles prog.tmp prog.pot"
: ${XGETTEXT=xgettext}
${XGETTEXT} -o prog.tmp --omit-header --add-location prog.rst
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
#: rstconv.help
msgid ""
"rstconv [-h|--help]    Displays this help\n"
"rstconv options        Convert rst file\n"
"\n"
"Options are:\n"
"  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)\n"
"  -o file    Write output to specified file (REQUIRED)\n"
"  -f format  Specifies the output format:\n"
"             po    GNU gettext .po (portable) format (DEFAULT)\n"
msgstr ""

#: rstconv.InvalidOption
msgid "Invalid option - "
msgstr ""

#: rstconv.OptionAlreadySpecified
msgid "Option has already been specified - "
msgstr ""

#: rstconv.NoOutFilename
msgid "No output filename specified"
msgstr ""

#: rstconv.InvalidOutputFormat
msgid "Invalid output format -"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} prog.ok prog.pot || exit 1

# The output of rstconv is slightly different:
# - ModuleName:ConstName instead of ModuleName.ConstName
# - no line wrapping in fpc versions < 2.6.0
# - extra newline at the end

tmpfiles="$tmpfiles prog.pot"
: ${RSTCONV=rstconv}
if (${RSTCONV} -o prog.pot -i prog.rst) >/dev/null 2>&1; then

tmpfiles="$tmpfiles prog.ok1"
cat <<EOF > prog.ok1
#: rstconv:help
msgid "rstconv [-h|--help]    Displays this help\nrstconv options        Convert rst file\n\nOptions are:\n  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)\n  -o file    Write output to specified file (REQUIRED)\n  -f format  Specifies the output format:\n             po    GNU gettext .po (portable) format (DEFAULT)\n"
msgstr ""

#: rstconv:InvalidOption
msgid "Invalid option - "
msgstr ""

#: rstconv:OptionAlreadySpecified
msgid "Option has already been specified - "
msgstr ""

#: rstconv:NoOutFilename
msgid "No output filename specified"
msgstr ""

#: rstconv:InvalidOutputFormat
msgid "Invalid output format -"
msgstr ""

EOF

tmpfiles="$tmpfiles prog.ok2"
cat <<EOF > prog.ok2
#: rstconv:help
msgid ""
"rstconv [-h|--help]    Displays this help\n"
"rstconv options        Convert rst file\n"
"\n"
"Options are:\n"
"  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)\n"
"  -o file    Write output to specified file (REQUIRED)\n"
"  -f format  Specifies the output format:\n"
"             po    GNU gettext .po (portable) format (DEFAULT)\n"
msgstr ""

#: rstconv:InvalidOption
msgid "Invalid option - "
msgstr ""

#: rstconv:OptionAlreadySpecified
msgid "Option has already been specified - "
msgstr ""

#: rstconv:NoOutFilename
msgid "No output filename specified"
msgstr ""

#: rstconv:InvalidOutputFormat
msgid "Invalid output format -"
msgstr ""

EOF

: ${DIFF=diff}
${DIFF} prog.ok1 prog.pot >/dev/null || ${DIFF} prog.ok2 prog.pot || exit 1

fi

rm -fr $tmpfiles

exit 0