Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / lang-rst
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test of gettext facilities in the RST format.
5
6 cat <<\EOF > prog.rst
7 # From the rstconv program itself.
8 rstconv.help='rstconv [-h|--help]    Displays this help'#10+
9 'rstconv options        Convert rst file'#10#10+
10 'Options are:'#10+
11 '  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)'#10+
12 '  -o file    Write output to specified file (REQUIRED)'#10+
13 '  -f format  Specifies the output format:'#10+
14 '             po    GNU gettext .po (portable) format (DEFAULT)'#10
15
16 rstconv.InvalidOption='Invalid option - '
17 rstconv.OptionAlreadySpecified='Option has already been specified - '
18 rstconv.NoOutFilename='No output filename specified'
19 rstconv.InvalidOutputFormat='Invalid output format -'
20 EOF
21
22 : ${XGETTEXT=xgettext}
23 ${XGETTEXT} -o prog.tmp --omit-header --add-location prog.rst || exit 1
24 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
25
26 cat <<EOF > prog.ok
27 #: rstconv.help
28 msgid ""
29 "rstconv [-h|--help]    Displays this help\n"
30 "rstconv options        Convert rst file\n"
31 "\n"
32 "Options are:\n"
33 "  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)\n"
34 "  -o file    Write output to specified file (REQUIRED)\n"
35 "  -f format  Specifies the output format:\n"
36 "             po    GNU gettext .po (portable) format (DEFAULT)\n"
37 msgstr ""
38
39 #: rstconv.InvalidOption
40 msgid "Invalid option - "
41 msgstr ""
42
43 #: rstconv.OptionAlreadySpecified
44 msgid "Option has already been specified - "
45 msgstr ""
46
47 #: rstconv.NoOutFilename
48 msgid "No output filename specified"
49 msgstr ""
50
51 #: rstconv.InvalidOutputFormat
52 msgid "Invalid output format -"
53 msgstr ""
54 EOF
55
56 : ${DIFF=diff}
57 ${DIFF} prog.ok prog.pot || exit 1
58
59 # The output of rstconv is slightly different:
60 # - ModuleName:ConstName instead of ModuleName.ConstName
61 # - no line wrapping in fpc versions < 2.6.0
62 # - extra newline at the end
63
64 : ${RSTCONV=rstconv}
65 if (${RSTCONV} -o prog.pot -i prog.rst) >/dev/null 2>&1; then
66
67 cat <<EOF > prog.ok1
68 #: rstconv:help
69 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"
70 msgstr ""
71
72 #: rstconv:InvalidOption
73 msgid "Invalid option - "
74 msgstr ""
75
76 #: rstconv:OptionAlreadySpecified
77 msgid "Option has already been specified - "
78 msgstr ""
79
80 #: rstconv:NoOutFilename
81 msgid "No output filename specified"
82 msgstr ""
83
84 #: rstconv:InvalidOutputFormat
85 msgid "Invalid output format -"
86 msgstr ""
87
88 EOF
89
90 cat <<EOF > prog.ok2
91 #: rstconv:help
92 msgid ""
93 "rstconv [-h|--help]    Displays this help\n"
94 "rstconv options        Convert rst file\n"
95 "\n"
96 "Options are:\n"
97 "  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)\n"
98 "  -o file    Write output to specified file (REQUIRED)\n"
99 "  -f format  Specifies the output format:\n"
100 "             po    GNU gettext .po (portable) format (DEFAULT)\n"
101 msgstr ""
102
103 #: rstconv:InvalidOption
104 msgid "Invalid option - "
105 msgstr ""
106
107 #: rstconv:OptionAlreadySpecified
108 msgid "Option has already been specified - "
109 msgstr ""
110
111 #: rstconv:NoOutFilename
112 msgid "No output filename specified"
113 msgstr ""
114
115 #: rstconv:InvalidOutputFormat
116 msgid "Invalid output format -"
117 msgstr ""
118
119 EOF
120
121 : ${DIFF=diff}
122 ${DIFF} prog.ok1 prog.pot >/dev/null || ${DIFF} prog.ok2 prog.pot || exit 1
123
124 fi
125
126 exit 0