summaryrefslogtreecommitdiffstats
path: root/doc/gettext_4.html
blob: daf1fc2ee0cf5e860edac2054383f89fcdc08850 (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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.51
     from gettext.texi on 19 April 2001 -->

<TITLE>GNU gettext utilities - 4  Making the PO Template File</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_3.html">previous</A>, <A HREF="gettext_5.html">next</A>, <A HREF="gettext_14.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC19" HREF="gettext_toc.html#TOC19">4  Making the PO Template File</A></H1>

<P>
After preparing the sources, the programmer creates a PO template file.
This section explains how to use <CODE>xgettext</CODE> for this purpose.

</P>



<H2><A NAME="SEC20" HREF="gettext_toc.html#TOC20">4.1  Invoking the <CODE>xgettext</CODE> Program</A></H2>


<PRE>
xgettext [<VAR>option</VAR>] <VAR>inputfile</VAR> ...
</PRE>

<DL COMPACT>

<DT><SAMP>`-a'</SAMP>
<DD>
<DT><SAMP>`--extract-all'</SAMP>
<DD>
Extract all strings.

<DT><SAMP>`-c [<VAR>tag</VAR>]'</SAMP>
<DD>
<DT><SAMP>`--add-comments[=<VAR>tag</VAR>]'</SAMP>
<DD>
Place comment block with <VAR>tag</VAR> (or those preceding keyword lines)
in output file.

<DT><SAMP>`-C'</SAMP>
<DD>
<DT><SAMP>`--c++'</SAMP>
<DD>
Recognize C++ style comments.

<DT><SAMP>`--debug'</SAMP>
<DD>
Use the flags <KBD>c-format</KBD> and <KBD>possible-c-format</KBD> to show who was
responsible for marking a message as a format string.  The latter form is
used if the <CODE>xgettext</CODE> program decided, the format form is used if
the programmer prescribed it.

By default only the <KBD>c-format</KBD> form is used.  The translator should
not have to care about these details.

<DT><SAMP>`-d <VAR>name</VAR>'</SAMP>
<DD>
<DT><SAMP>`--default-domain=<VAR>name</VAR>'</SAMP>
<DD>
Use <TT>`<VAR>name</VAR>.po'</TT> for output (instead of <TT>`messages.po'</TT>).

The special domain name <TT>`-'</TT> or <TT>`/dev/stdout'</TT> means to write
the output to <TT>`stdout'</TT>.

<DT><SAMP>`-D <VAR>directory</VAR>'</SAMP>
<DD>
<DT><SAMP>`--directory=<VAR>directory</VAR>'</SAMP>
<DD>
Change to <VAR>directory</VAR> before beginning to search and scan source
files.  The resulting <TT>`.po'</TT> file will be written relative to the
original directory, though.

<DT><SAMP>`-f <VAR>file</VAR>'</SAMP>
<DD>
<DT><SAMP>`--files-from=<VAR>file</VAR>'</SAMP>
<DD>
Read the names of the input files from <VAR>file</VAR> instead of getting
them from the command line.

<DT><SAMP>`--force'</SAMP>
<DD>
Always write an output file even if no message is defined.

<DT><SAMP>`-h'</SAMP>
<DD>
<DT><SAMP>`--help'</SAMP>
<DD>
Display this help and exit.

<DT><SAMP>`-I <VAR>list</VAR>'</SAMP>
<DD>
<DT><SAMP>`--input-path=<VAR>list</VAR>'</SAMP>
<DD>
List of directories searched for input files.

<DT><SAMP>`-j'</SAMP>
<DD>
<DT><SAMP>`--join-existing'</SAMP>
<DD>
Join messages with existing file.

<DT><SAMP>`-k <VAR>word</VAR>'</SAMP>
<DD>
<DT><SAMP>`--keyword[=<VAR>keywordspec</VAR>]'</SAMP>
<DD>
Additional keyword to be looked for (without <VAR>keywordspec</VAR> means not to
use default keywords).

If <VAR>keywordspec</VAR> is a C identifer <VAR>id</VAR>, <CODE>xgettext</CODE> looks
for strings in the first argument of each call to the function or macro
<VAR>id</VAR>.  If <VAR>keywordspec</VAR> is of the form
<SAMP>`<VAR>id</VAR>:<VAR>argnum</VAR>'</SAMP>, <CODE>xgettext</CODE> looks for strings in the
<VAR>argnum</VAR>th argument of the call.  If <VAR>keywordspec</VAR> is of the form
<SAMP>`<VAR>id</VAR>:<VAR>argnum1</VAR>,<VAR>argnum2</VAR>'</SAMP>, <CODE>xgettext</CODE> looks for
strings in the <VAR>argnum1</VAR>st argument and in the <VAR>argnum2</VAR>nd argument
of the call, and treats them as singular/plural variants for a message
with plural handling.

The default keyword specifications, which are always looked for if not
explicitly disabled, are <CODE>gettext</CODE>, <CODE>dgettext:2</CODE>,
<CODE>dcgettext:2</CODE>, <CODE>ngettext:1,2</CODE>, <CODE>dngettext:2,3</CODE>,
<CODE>dcngettext:2,3</CODE>, and <CODE>gettext_noop</CODE>.

<DT><SAMP>`-m [<VAR>string</VAR>]'</SAMP>
<DD>
<DT><SAMP>`--msgstr-prefix[=<VAR>string</VAR>]'</SAMP>
<DD>
Use <VAR>string</VAR> or "" as prefix for msgstr entries.

<DT><SAMP>`-M [<VAR>string</VAR>]'</SAMP>
<DD>
<DT><SAMP>`--msgstr-suffix[=<VAR>string</VAR>]'</SAMP>
<DD>
Use <VAR>string</VAR> or "" as suffix for msgstr entries.

<DT><SAMP>`--no-location'</SAMP>
<DD>
Do not write <SAMP>`#: <VAR>filename</VAR>:<VAR>line</VAR>'</SAMP> lines.

<DT><SAMP>`-n'</SAMP>
<DD>
<DT><SAMP>`--add-location'</SAMP>
<DD>
Generate <SAMP>`#: <VAR>filename</VAR>:<VAR>line</VAR>'</SAMP> lines (default).

<DT><SAMP>`--omit-header'</SAMP>
<DD>
Don't write header with <SAMP>`msgid ""'</SAMP> entry.

This is useful for testing purposes because it eliminates a source
of variance for generated <CODE>.gmo</CODE> files.  We can ship some of
these files in the GNU <CODE>gettext</CODE> package, and the result of
regenerating them through <CODE>msgfmt</CODE> should yield the same values.

<DT><SAMP>`-p <VAR>dir</VAR>'</SAMP>
<DD>
<DT><SAMP>`--output-dir=<VAR>dir</VAR>'</SAMP>
<DD>
Output files will be placed in directory <VAR>dir</VAR>.

<DT><SAMP>`-s'</SAMP>
<DD>
<DT><SAMP>`--sort-output'</SAMP>
<DD>
Generate sorted output and remove duplicates.

<DT><SAMP>`--strict'</SAMP>
<DD>
Write out a strict Uniforum conforming PO file.

<DT><SAMP>`-v'</SAMP>
<DD>
<DT><SAMP>`--version'</SAMP>
<DD>
Output version information and exit.

<DT><SAMP>`-x <VAR>file</VAR>'</SAMP>
<DD>
<DT><SAMP>`--exclude-file=<VAR>file</VAR>'</SAMP>
<DD>
Entries from <VAR>file</VAR> are not extracted.

</DL>

<P>
Search path for supplementary PO files is:
<TT>`/usr/local/share/nls/src/'</TT>.

</P>
<P>
If <VAR>inputfile</VAR> is <SAMP>`-'</SAMP>, standard input is read.

</P>
<P>
This implementation of <CODE>xgettext</CODE> is able to process a few awkward
cases, like strings in preprocessor macros, ANSI concatenation of
adjacent strings, and escaped end of lines for continued strings.

</P>
<P><HR><P>
Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_3.html">previous</A>, <A HREF="gettext_5.html">next</A>, <A HREF="gettext_14.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
</BODY>
</HTML>