5
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
<meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/">
7
<title>Babel: Command-Line Interface</title>
8
<link rel="stylesheet" href="common/style/edgewall.css" type="text/css">
11
<div class="document" id="command-line-interface">
13
<span class="projinfo">Babel 0.9.6</span>
14
<a href="index.html">Documentation Index</a>
16
<h1 class="title">Command-Line Interface</h1>
17
<p>Babel includes a command-line interface for working with message catalogs,
18
similar to the various GNU <tt class="docutils literal">gettext</tt> tools commonly available on Linux/Unix
20
<div class="contents topic" id="contents">
21
<p class="topic-title first">Contents</p>
22
<ul class="auto-toc simple">
23
<li><a class="reference internal" href="#compile" id="id1">1 compile</a></li>
24
<li><a class="reference internal" href="#extract" id="id2">2 extract</a></li>
25
<li><a class="reference internal" href="#init" id="id3">3 init</a></li>
26
<li><a class="reference internal" href="#update" id="id4">4 update</a></li>
29
<p>When properly installed, Babel provides a script called <tt class="docutils literal">pybabel</tt>:</p>
30
<pre class="literal-block">
32
usage: pybabel command [options] [args]
35
--version show program's version number and exit
36
-h, --help show this help message and exit
37
--list-locales print all known locales and exit
38
-v, --verbose print as much as possible
39
-q, --quiet print as little as possible
42
compile compile message catalogs to MO files
43
extract extract messages from source files and generate a POT file
44
init create new message catalogs from a POT file
45
update update existing message catalogs from a POT file
47
<p>The <tt class="docutils literal">pybabel</tt> script provides a number of sub-commands that do the actual
48
work. Those sub-commands are described below.</p>
49
<div class="section" id="compile">
51
<p>The <tt class="docutils literal">compile</tt> sub-command can be used to compile translation catalogs into
53
<pre class="literal-block">
54
$ pybabel compile --help
55
usage: pybabel compile [options]
57
compile message catalogs to MO files
60
-h, --help show this help message and exit
61
-D DOMAIN, --domain=DOMAIN
62
domain of MO and PO files (default 'messages')
63
-d DIR, --directory=DIR
64
base directory of catalog files
65
-l LOCALE, --locale=LOCALE
67
-i FILE, --input-file=FILE
68
name of the input file
69
-o FILE, --output-file=FILE
70
name of the output file (default
71
'<output_dir>/<locale>/LC_MESSAGES/<domain>.mo')
72
-f, --use-fuzzy also include fuzzy translations (default False)
73
--statistics print statistics about translations
75
<p>If <tt class="docutils literal">directory</tt> is specified, but <tt class="docutils literal"><span class="pre">output-file</span></tt> is not, the default filename
76
of the output file will be:</p>
77
<pre class="literal-block">
78
<directory>/<locale>/LC_MESSAGES/<domain>.mo
80
<p>If neither the <tt class="docutils literal">input_file</tt> nor the <tt class="docutils literal">locale</tt> option is set, this command
81
looks for all catalog files in the base directory that match the given domain,
82
and compiles each of them to MO files in the same directory.</p>
84
<div class="section" id="extract">
86
<p>The <tt class="docutils literal">extract</tt> sub-command can be used to extract localizable messages from
87
a collection of source files:</p>
88
<pre class="literal-block">
89
$ pybabel extract --help
90
usage: pybabel extract [options] dir1 <dir2> ...
92
extract messages from source files and generate a POT file
95
-h, --help show this help message and exit
96
--charset=CHARSET charset to use in the output (default "utf-8")
97
-k KEYWORDS, --keyword=KEYWORDS
98
keywords to look for in addition to the defaults. You
99
can specify multiple -k flags on the command line.
100
--no-default-keywords
101
do not include the default keywords
102
-F MAPPING_FILE, --mapping=MAPPING_FILE
103
path to the extraction mapping file
104
--no-location do not include location comments with filename and
106
--omit-header do not include msgid "" entry in header
107
-o OUTPUT, --output=OUTPUT
108
path to the output POT file
109
-w WIDTH, --width=WIDTH
110
set output line width (default 76)
111
--no-wrap do not break long message lines, longer than the
112
output line width, into several lines
113
--sort-output generate sorted output (default False)
114
--sort-by-file sort output by file location (default False)
115
--msgid-bugs-address=EMAIL@ADDRESS
116
set report address for msgid
117
--copyright-holder=COPYRIGHT_HOLDER
118
set copyright holder in output
119
-c TAG, --add-comments=TAG
120
place comment block with TAG (or those preceding
121
keyword lines) in output file. One TAG per argument
125
<div class="section" id="init">
127
<p>The <cite>init</cite> sub-command creates a new translations catalog based on a PO
129
<pre class="literal-block">
130
$ pybabel init --help
131
usage: pybabel init [options]
133
create new message catalogs from a POT file
136
-h, --help show this help message and exit
137
-D DOMAIN, --domain=DOMAIN
138
domain of PO file (default 'messages')
139
-i FILE, --input-file=FILE
140
name of the input file
141
-d DIR, --output-dir=DIR
142
path to output directory
143
-o FILE, --output-file=FILE
144
name of the output file (default
145
'<output_dir>/<locale>/LC_MESSAGES/<domain>.po')
146
-l LOCALE, --locale=LOCALE
147
locale for the new localized catalog
150
<div class="section" id="update">
152
<p>The <cite>update</cite> sub-command updates an existing new translations catalog based on
153
a PO template file:</p>
154
<pre class="literal-block">
155
$ pybabel update --help
156
usage: pybabel update [options]
158
update existing message catalogs from a POT file
161
-h, --help show this help message and exit
162
-D DOMAIN, --domain=DOMAIN
163
domain of PO file (default 'messages')
164
-i FILE, --input-file=FILE
165
name of the input file
166
-d DIR, --output-dir=DIR
167
path to output directory
168
-o FILE, --output-file=FILE
169
name of the output file (default
170
'<output_dir>/<locale>/LC_MESSAGES/<domain>.po')
171
-l LOCALE, --locale=LOCALE
172
locale of the translations catalog
173
--ignore-obsolete do not include obsolete messages in the output
175
-N, --no-fuzzy-matching
176
do not use fuzzy matching (default False)
177
--previous keep previous msgids of translated messages (default
180
<p>If <tt class="docutils literal">output_dir</tt> is specified, but <tt class="docutils literal"><span class="pre">output-file</span></tt> is not, the default
181
filename of the output file will be:</p>
182
<pre class="literal-block">
183
<directory>/<locale>/LC_MESSAGES/<domain>.mo
185
<p>If neither the <tt class="docutils literal">output_file</tt> nor the <tt class="docutils literal">locale</tt> option is set, this command
186
looks for all catalog files in the base directory that match the given domain,
187
and updates each of them.</p>
190
Visit the Babel open source project at
191
<a href="http://babel.edgewall.org/">http://babel.edgewall.org/</a>