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
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/">
<title>Babel: Command-Line Interface</title>
<link rel="stylesheet" href="common/style/edgewall.css" type="text/css">
</head>
<body>
<div class="document" id="command-line-interface">
<div id="navigation">
<span class="projinfo">Babel 0.9.1</span>
<a href="index.html">Documentation Index</a>
</div>
<h1 class="title">Command-Line Interface</h1>
<p>Babel includes a command-line interface for working with message catalogs,
similar to the various GNU <tt class="docutils literal"><span class="pre">gettext</span></tt> tools commonly available on Linux/Unix
systems.</p>
<div class="contents topic">
<p class="topic-title first"><a id="contents" name="contents">Contents</a></p>
<ul class="auto-toc simple">
<li><a class="reference" href="#compile" id="id1" name="id1">1 compile</a></li>
<li><a class="reference" href="#extract" id="id2" name="id2">2 extract</a></li>
<li><a class="reference" href="#init" id="id3" name="id3">3 init</a></li>
<li><a class="reference" href="#update" id="id4" name="id4">4 update</a></li>
</ul>
</div>
<p>When properly installed, Babel provides a script called <tt class="docutils literal"><span class="pre">pybabel</span></tt>:</p>
<pre class="literal-block">
$ pybabel --help
usage: pybabel subcommand [options] [args]
options:
--version show program's version number and exit
-h, --help show this help message and exit
subcommands:
compile compile message catalogs to MO files
extract extract messages from source files and generate a POT file
init create new message catalogs from a POT file
update update existing message catalogs from a POT file
</pre>
<p>The <tt class="docutils literal"><span class="pre">pybabel</span></tt> script provides a number of sub-commands that do the actual
work. Those sub-commands are described below.</p>
<div class="section">
<h1><a id="compile" name="compile">1 compile</a></h1>
<p>The <tt class="docutils literal"><span class="pre">compile</span></tt> sub-command can be used to compile translation catalogs into
binary MO files:</p>
<pre class="literal-block">
$ pybabel compile --help
usage: pybabel compile [options]
compile message catalogs to MO files
options:
-h, --help show this help message and exit
-D DOMAIN, --domain=DOMAIN
domain of MO and PO files (default 'messages')
-d DIR, --directory=DIR
base directory of catalog files
-l LOCALE, --locale=LOCALE
locale of the catalog
-i FILE, --input-file=FILE
name of the input file
-o FILE, --output-file=FILE
name of the output file (default
'<output_dir>/<locale>/LC_MESSAGES/<domain>.mo')
-f, --use-fuzzy also include fuzzy translations (default False)
</pre>
<p>If <tt class="docutils literal"><span class="pre">directory</span></tt> is specified, but <tt class="docutils literal"><span class="pre">output-file</span></tt> is not, the default filename
of the output file will be:</p>
<pre class="literal-block">
<directory>/<locale>/LC_MESSAGES/<domain>.mo
</pre>
<p>If neither the <tt class="docutils literal"><span class="pre">input_file</span></tt> nor the <tt class="docutils literal"><span class="pre">locale</span></tt> option is set, this command
looks for all catalog files in the base directory that match the given domain,
and compiles each of them to MO files in the same directory.</p>
</div>
<div class="section">
<h1><a id="extract" name="extract">2 extract</a></h1>
<p>The <tt class="docutils literal"><span class="pre">extract</span></tt> sub-command can be used to extract localizable messages from
a collection of source files:</p>
<pre class="literal-block">
$ pybabel extract --help
usage: pybabel extract [options] dir1 <dir2> ...
extract messages from source files and generate a POT file
options:
-h, --help show this help message and exit
--charset=CHARSET charset to use in the output
-k KEYWORDS, --keyword=KEYWORDS
keywords to look for in addition to the defaults. You
can specify multiple -k flags on the command line.
--no-default-keywords
do not include the default keywords
-F MAPPING_FILE, --mapping=MAPPING_FILE
path to the extraction mapping file
--no-location do not include location comments with filename and
line number
--omit-header do not include msgid "" entry in header
-o OUTPUT, --output=OUTPUT
path to the output POT file
-w WIDTH, --width=WIDTH
set output line width (default 76)
--no-wrap do not break long message lines, longer than the
output line width, into several lines
--sort-output generate sorted output (default False)
--sort-by-file sort output by file location (default False)
--msgid-bugs-address=EMAIL@ADDRESS
set report address for msgid
--copyright-holder=COPYRIGHT_HOLDER
set copyright holder in output
-c TAG, --add-comments=TAG
place comment block with TAG (or those preceding
keyword lines) in output file. One TAG per argument
call
</pre>
</div>
<div class="section">
<h1><a id="init" name="init">3 init</a></h1>
<p>The <cite>init</cite> sub-command creates a new translations catalog based on a PO
template file:</p>
<pre class="literal-block">
$ pybabel init --help
usage: pybabel init [options]
create new message catalogs from a POT file
options:
-h, --help show this help message and exit
-D DOMAIN, --domain=DOMAIN
domain of PO file (defaults to lower-cased project
name)
-i INPUT_FILE, --input-file=INPUT_FILE
name of the input file
-d OUTPUT_DIR, --output-dir=OUTPUT_DIR
path to output directory
-o OUTPUT_FILE, --output-file=OUTPUT_FILE
name of the output file (default
'<output_dir>/<locale>/<domain>.po')
-l LOCALE, --locale=LOCALE
locale for the new localized catalog
--first-author=FIRST_AUTHOR_NAME
name of first author
--first-author-email=FIRST_AUTHOR_EMAIL
email of first author
--project-name=NAME the project name
--project-version=VERSION
the project version
</pre>
</div>
<div class="section">
<h1><a id="update" name="update">4 update</a></h1>
<p>The <cite>update</cite> sub-command updates an existing new translations catalog based on
a PO template file:</p>
<pre class="literal-block">
$ pybabel update --help
usage: pybabel update [options]
update existing message catalogs from a POT file
options:
-h, --help show this help message and exit
-D DOMAIN, --domain=DOMAIN
domain of PO file (default 'messages')
-i FILE, --input-file=FILE
name of the input file
-d DIR, --output-dir=DIR
path to output directory
-o FILE, --output-file=FILE
name of the output file (default
'<output_dir>/<locale>/LC_MESSAGES/<domain>.po')
-l LOCALE, --locale=LOCALE
locale of the translations catalog
--ignore-obsolete do not include obsolete messages in the output
(default False)
</pre>
<p>If <tt class="docutils literal"><span class="pre">output_dir</span></tt> is specified, but <tt class="docutils literal"><span class="pre">output-file</span></tt> is not, the default
filename of the output file will be:</p>
<pre class="literal-block">
<directory>/<locale>/LC_MESSAGES/<domain>.mo
</pre>
<p>If neither the <tt class="docutils literal"><span class="pre">output_file</span></tt> nor the <tt class="docutils literal"><span class="pre">locale</span></tt> option is set, this command
looks for all catalog files in the base directory that match the given domain,
and updates each of them.</p>
</div>
<div id="footer">
Visit the Babel open source project at
<a href="http://babel.edgewall.org/">http://babel.edgewall.org/</a>
</div>
</div>
</body>
</html>
|