~ubuntu-branches/ubuntu/trusty/python-babel/trusty

« back to all changes in this revision

Viewing changes to doc/cmdline.html

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-10-28 10:11:31 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131028101131-zwbmm8sc29iemmlr
Tags: 1.3-2ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/rules: Run the testsuite during builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html>
2
 
 
3
 
<html lang="en">
4
 
<head>
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">
9
 
</head>
10
 
<body>
11
 
<div class="document" id="command-line-interface">
12
 
    <div id="navigation">
13
 
      <span class="projinfo">Babel 0.9.6</span>
14
 
      <a href="index.html">Documentation Index</a>
15
 
    </div>
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
19
 
systems.</p>
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>
27
 
</ul>
28
 
</div>
29
 
<p>When properly installed, Babel provides a script called <tt class="docutils literal">pybabel</tt>:</p>
30
 
<pre class="literal-block">
31
 
$ pybabel --help
32
 
usage: pybabel command [options] [args]
33
 
 
34
 
options:
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
40
 
 
41
 
commands:
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
46
 
</pre>
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">
50
 
<h1>1   compile</h1>
51
 
<p>The <tt class="docutils literal">compile</tt> sub-command can be used to compile translation catalogs into
52
 
binary MO files:</p>
53
 
<pre class="literal-block">
54
 
$ pybabel compile --help
55
 
usage: pybabel compile [options]
56
 
 
57
 
compile message catalogs to MO files
58
 
 
59
 
options:
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
66
 
                        locale of the catalog
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
 
                        '&lt;output_dir&gt;/&lt;locale&gt;/LC_MESSAGES/&lt;domain&gt;.mo')
72
 
  -f, --use-fuzzy       also include fuzzy translations (default False)
73
 
  --statistics          print statistics about translations
74
 
</pre>
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
 
&lt;directory&gt;/&lt;locale&gt;/LC_MESSAGES/&lt;domain&gt;.mo
79
 
</pre>
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>
83
 
</div>
84
 
<div class="section" id="extract">
85
 
<h1>2   extract</h1>
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 &lt;dir2&gt; ...
91
 
 
92
 
extract messages from source files and generate a POT file
93
 
 
94
 
options:
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
105
 
                        line number
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
122
 
                        call
123
 
</pre>
124
 
</div>
125
 
<div class="section" id="init">
126
 
<h1>3   init</h1>
127
 
<p>The <cite>init</cite> sub-command creates a new translations catalog based on a PO
128
 
template file:</p>
129
 
<pre class="literal-block">
130
 
$ pybabel init --help
131
 
usage: pybabel init [options]
132
 
 
133
 
create new message catalogs from a POT file
134
 
 
135
 
options:
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
 
                        '&lt;output_dir&gt;/&lt;locale&gt;/LC_MESSAGES/&lt;domain&gt;.po')
146
 
  -l LOCALE, --locale=LOCALE
147
 
                        locale for the new localized catalog
148
 
</pre>
149
 
</div>
150
 
<div class="section" id="update">
151
 
<h1>4   update</h1>
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]
157
 
 
158
 
update existing message catalogs from a POT file
159
 
 
160
 
options:
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
 
                        '&lt;output_dir&gt;/&lt;locale&gt;/LC_MESSAGES/&lt;domain&gt;.po')
171
 
  -l LOCALE, --locale=LOCALE
172
 
                        locale of the translations catalog
173
 
  --ignore-obsolete     do not include obsolete messages in the output
174
 
                        (default False)
175
 
  -N, --no-fuzzy-matching
176
 
                        do not use fuzzy matching (default False)
177
 
  --previous            keep previous msgids of translated messages (default
178
 
                        False)
179
 
</pre>
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
 
&lt;directory&gt;/&lt;locale&gt;/LC_MESSAGES/&lt;domain&gt;.mo
184
 
</pre>
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>
188
 
</div>
189
 
    <div id="footer">
190
 
      Visit the Babel open source project at
191
 
      <a href="http://babel.edgewall.org/">http://babel.edgewall.org/</a>
192
 
    </div>
193
 
  </div>
194
 
</body>
195
 
</html>