summaryrefslogtreecommitdiffstats
path: root/doc/xgettext.texi
blob: a3e7dee9ead5d2bc7daf43db43b6511c9742f3a8 (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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
@pindex xgettext
@cindex @code{xgettext} program, usage
@example
xgettext [@var{option}] [@var{inputfile}] @dots{}
@end example

The @code{xgettext} program extracts translatable strings from given
input files.

@subsection Input file location

@table @samp
@item @var{inputfile} @dots{}
Input files.

@item -f @var{file}
@itemx --files-from=@var{file}
@opindex -f@r{, @code{xgettext} option}
@opindex --files-from@r{, @code{xgettext} option}
Read the names of the input files from @var{file} instead of getting
them from the command line.

@item -D @var{directory}
@itemx --directory=@var{directory}
@opindex -D@r{, @code{xgettext} option}
@opindex --directory@r{, @code{xgettext} option}
Add @var{directory} to the list of directories.  Source files are
searched relative to this list of directories.  The resulting @file{.po}
file will be written relative to the current directory, though.

@end table

If @var{inputfile} is @samp{-}, standard input is read.

@subsection Output file location

@table @samp
@item -d @var{name}
@itemx --default-domain=@var{name}
@opindex -d@r{, @code{xgettext} option}
@opindex --default-domain@r{, @code{xgettext} option}
Use @file{@var{name}.po} for output (instead of @file{messages.po}).

@item -o @var{file}
@itemx --output=@var{file}
@opindex -o@r{, @code{xgettext} option}
@opindex --output@r{, @code{xgettext} option}
Write output to specified file (instead of @file{@var{name}.po} or
@file{messages.po}).

@item -p @var{dir}
@itemx --output-dir=@var{dir}
@opindex -p@r{, @code{xgettext} option}
@opindex --output-dir@r{, @code{xgettext} option}
Output files will be placed in directory @var{dir}.

@end table

@cindex output to stdout, @code{xgettext}
If the output @var{file} is @samp{-} or @samp{/dev/stdout}, the output
is written to standard output.

@subsection Choice of input file language

@table @samp
@item -L @var{name}
@itemx --language=@var{name}
@opindex -L@r{, @code{xgettext} option}
@opindex --language@r{, @code{xgettext} option}
@cindex supported languages, @code{xgettext}
Specifies the language of the input files.  The supported languages
are @code{C}, @code{C++}, @code{ObjectiveC}, @code{PO}, @code{Java},
@code{YCP}.

@item -C
@itemx --c++
@opindex -C@r{, @code{xgettext} option}
@opindex --c++@r{, @code{xgettext} option}
This is a shorthand for @code{--language=C++}.

@end table

By default the language is guessed depending on the input file name
extension.

@subsection Operation mode

@table @samp
@item -j
@itemx --join-existing
@opindex -j@r{, @code{xgettext} option}
@opindex --join-existing@r{, @code{xgettext} option}
Join messages with existing file.

@item -x @var{file}
@itemx --exclude-file=@var{file}
@opindex -x@r{, @code{xgettext} option}
@opindex --exclude-file@r{, @code{xgettext} option}
Entries from @var{file} are not extracted.  @var{file} should be a PO or
POT file.

@item -c [@var{tag}]
@itemx --add-comments[=@var{tag}]
@opindex -c@r{, @code{xgettext} option}
@opindex --add-comments@r{, @code{xgettext} option}
Place comment block with @var{tag} (or those preceding keyword lines)
in output file.

@end table

@subsection Language=C/C++ specific options

@table @samp
@item -a
@itemx --extract-all
@opindex -a@r{, @code{xgettext} option}
@opindex --extract-all@r{, @code{xgettext} option}
Extract all strings.

@item -k @var{keywordspec}
@itemx --keyword[=@var{keywordspec}]
@opindex -k@r{, @code{xgettext} option}
@opindex --keyword@r{, @code{xgettext} option}
Additional keyword to be looked for (without @var{keywordspec} means not to
use default keywords).

@cindex adding keywords, @code{xgettext}
If @var{keywordspec} is a C identifer @var{id}, @code{xgettext} looks
for strings in the first argument of each call to the function or macro
@var{id}.  If @var{keywordspec} is of the form
@samp{@var{id}:@var{argnum}}, @code{xgettext} looks for strings in the
@var{argnum}th argument of the call.  If @var{keywordspec} is of the form
@samp{@var{id}:@var{argnum1},@var{argnum2}}, @code{xgettext} looks for
strings in the @var{argnum1}st argument and in the @var{argnum2}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{dgettext:2},
@code{dcgettext:2}, @code{ngettext:1,2}, @code{dngettext:2,3},
@code{dcngettext:2,3}, and @code{gettext_noop}.

@item -T
@itemx --trigraphs
@opindex -T@r{, @code{xgettext} option}
@opindex --trigraphs@r{, @code{xgettext} option}
@cindex C trigraphs
Understand ANSI C trigraphs for input.

@itemx --debug
@opindex --debug@r{, @code{xgettext} option}
@cindex debugging messages marked as format strings
Use the flags @kbd{c-format} and @kbd{possible-c-format} to show who was
responsible for marking a message as a format string.  The latter form is
used if the @code{xgettext} program decided, the format form is used if
the programmer prescribed it.

By default only the @kbd{c-format} form is used.  The translator should
not have to care about these details.

@end table

This implementation of @code{xgettext} 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.

@subsection Output details

@c --no-escape and --escape omitted on purpose.  They are not useful.

@table @samp
@item --force-po
@opindex --force-po@r{, @code{xgettext} option}
Always write an output file even if no message is defined.

@item -i
@itemx --indent
@opindex -i@r{, @code{xgettext} option}
@opindex --indent@r{, @code{xgettext} option}
Write the .po file using indented style.

@item --no-location
@opindex --no-location@r{, @code{xgettext} option}
Do not write @samp{#: @var{filename}:@var{line}} lines.

@item -n
@itemx --add-location
@opindex -n@r{, @code{xgettext} option}
@opindex --add-location@r{, @code{xgettext} option}
Generate @samp{#: @var{filename}:@var{line}} lines (default).

@item --strict
@opindex --strict@r{, @code{xgettext} option}
Write out a strict Uniforum conforming PO file.  Note that this
Uniforum format should be avoided because it doesn't support the
GNU extensions.

@item -w @var{number}
@itemx --width=@var{number}
@opindex -w@r{, @code{xgettext} option}
@opindex --width@r{, @code{xgettext} option}
Set the output page width.  Long strings in the output files will be
split across multiple lines in order to ensure that each line's width
(= number of screen columns) is less or equal to the given @var{number}.

@item -s
@itemx --sort-output
@opindex -s@r{, @code{xgettext} option}
@opindex --sort-output@r{, @code{xgettext} option}
@cindex sorting output of @code{xgettext}
Generate sorted output.  Note that using this option makes it much harder
for the translator to understand each message's context.

@item -F
@itemx --sort-by-file
@opindex -F@r{, @code{xgettext} option}
@opindex --sort-by-file@r{, @code{xgettext} option}
Sort output by file location.

@item --omit-header
@opindex --omit-header@r{, @code{xgettext} option}
Don't write header with @samp{msgid ""} entry.

@cindex testing @file{.po} files for equivalence
This is useful for testing purposes because it eliminates a source
of variance for generated @code{.gmo} files.  With @code{--omit-header},
two invocations of @code{xgettext} on the same files with the same
options at different times are guaranteed to produce the same results.

@item --copyright-holder=@var{string}
@opindex --copyright-holder@r{, @code{xgettext} option}
Set the copyright holder in the output.  @var{string} should be the
copyright holder of the surrounding package.  (Note that the msgstr
strings, extracted from the package's sources, belong to the copyright
holder of the package.)  Translators are expected to transfer or disclaim
the copyright for their translations, so that package maintainers can
distribute them without legal risk.  If @var{string} is empty, the output
files are marked as being in the public domain; in this case, the translators
are expected to disclaim their copyright, again so that package maintainers
can distribute them without legal risk.

The default value for @var{string} is the Free Software Foundation, Inc.,
simply because @code{xgettext} was first used in the GNU project.

@item --foreign-user
@opindex --foreign-user@r{, @code{xgettext} option}
Omit FSF copyright in output.  This option is equivalent to
@samp{--copyright-holder=''}.  It can be useful for packages outside the GNU
project that want their translations to be in the public domain.

@item -m [@var{string}]
@itemx --msgstr-prefix[=@var{string}]
@opindex -m@r{, @code{xgettext} option}
@opindex --msgstr-prefix@r{, @code{xgettext} option}
Use @var{string} (or "" if not specified) as prefix for msgstr entries.

@item -M [@var{string}]
@itemx --msgstr-suffix[=@var{string}]
@opindex -M@r{, @code{xgettext} option}
@opindex --msgstr-suffix@r{, @code{xgettext} option}
Use @var{string} (or "" if not specified) as suffix for msgstr entries.

@end table

@subsection Informative output

@table @samp
@item -h
@itemx --help
@opindex -h@r{, @code{xgettext} option}
@opindex --help@r{, @code{xgettext} option}
Display this help and exit.

@item -V
@itemx --version
@opindex -V@r{, @code{xgettext} option}
@opindex --version@r{, @code{xgettext} option}
Output version information and exit.

@end table