263
|
1 .. -*- mode: rst; encoding: utf-8 -*-
|
|
2
|
|
3 ======================
|
|
4 Command-Line Interface
|
|
5 ======================
|
|
6
|
|
7 Babel includes a command-line interface for working with message catalogs,
|
|
8 similar to the various GNU ``gettext`` tools commonly available on Linux/Unix
|
|
9 systems.
|
|
10
|
|
11
|
|
12 .. contents:: Contents
|
|
13 :depth: 2
|
|
14 .. sectnum::
|
|
15
|
|
16
|
|
17 When properly installed, Babel provides a script called ``pybabel``::
|
|
18
|
323
|
19 $ pybabel --help
|
|
20 usage: pybabel command [options] [args]
|
263
|
21
|
|
22 options:
|
323
|
23 --version show program's version number and exit
|
|
24 -h, --help show this help message and exit
|
|
25 --list-locales print all known locales and exit
|
|
26 -v, --verbose print as much as possible
|
|
27 -q, --quiet print as little as possible
|
263
|
28
|
323
|
29 commands:
|
|
30 compile compile message catalogs to MO files
|
|
31 extract extract messages from source files and generate a POT file
|
|
32 init create new message catalogs from a POT file
|
|
33 update update existing message catalogs from a POT file
|
263
|
34
|
|
35 The ``pybabel`` script provides a number of sub-commands that do the actual
|
|
36 work. Those sub-commands are described below.
|
|
37
|
|
38
|
|
39 compile
|
|
40 =======
|
|
41
|
|
42 The ``compile`` sub-command can be used to compile translation catalogs into
|
|
43 binary MO files::
|
|
44
|
|
45 $ pybabel compile --help
|
|
46 usage: pybabel compile [options]
|
323
|
47
|
263
|
48 compile message catalogs to MO files
|
323
|
49
|
263
|
50 options:
|
|
51 -h, --help show this help message and exit
|
|
52 -D DOMAIN, --domain=DOMAIN
|
|
53 domain of MO and PO files (default 'messages')
|
|
54 -d DIR, --directory=DIR
|
|
55 base directory of catalog files
|
|
56 -l LOCALE, --locale=LOCALE
|
|
57 locale of the catalog
|
|
58 -i FILE, --input-file=FILE
|
|
59 name of the input file
|
|
60 -o FILE, --output-file=FILE
|
|
61 name of the output file (default
|
|
62 '<output_dir>/<locale>/LC_MESSAGES/<domain>.mo')
|
|
63 -f, --use-fuzzy also include fuzzy translations (default False)
|
323
|
64 --statistics print statistics about translations
|
263
|
65
|
|
66 If ``directory`` is specified, but ``output-file`` is not, the default filename
|
|
67 of the output file will be::
|
|
68
|
|
69 <directory>/<locale>/LC_MESSAGES/<domain>.mo
|
|
70
|
|
71 If neither the ``input_file`` nor the ``locale`` option is set, this command
|
|
72 looks for all catalog files in the base directory that match the given domain,
|
|
73 and compiles each of them to MO files in the same directory.
|
|
74
|
|
75
|
|
76 extract
|
|
77 =======
|
|
78
|
|
79 The ``extract`` sub-command can be used to extract localizable messages from
|
|
80 a collection of source files::
|
|
81
|
|
82 $ pybabel extract --help
|
|
83 usage: pybabel extract [options] dir1 <dir2> ...
|
323
|
84
|
263
|
85 extract messages from source files and generate a POT file
|
323
|
86
|
263
|
87 options:
|
|
88 -h, --help show this help message and exit
|
323
|
89 --charset=CHARSET charset to use in the output (default "utf-8")
|
263
|
90 -k KEYWORDS, --keyword=KEYWORDS
|
|
91 keywords to look for in addition to the defaults. You
|
|
92 can specify multiple -k flags on the command line.
|
|
93 --no-default-keywords
|
|
94 do not include the default keywords
|
|
95 -F MAPPING_FILE, --mapping=MAPPING_FILE
|
|
96 path to the extraction mapping file
|
|
97 --no-location do not include location comments with filename and
|
|
98 line number
|
|
99 --omit-header do not include msgid "" entry in header
|
|
100 -o OUTPUT, --output=OUTPUT
|
|
101 path to the output POT file
|
|
102 -w WIDTH, --width=WIDTH
|
|
103 set output line width (default 76)
|
|
104 --no-wrap do not break long message lines, longer than the
|
|
105 output line width, into several lines
|
|
106 --sort-output generate sorted output (default False)
|
|
107 --sort-by-file sort output by file location (default False)
|
|
108 --msgid-bugs-address=EMAIL@ADDRESS
|
|
109 set report address for msgid
|
|
110 --copyright-holder=COPYRIGHT_HOLDER
|
|
111 set copyright holder in output
|
|
112 -c TAG, --add-comments=TAG
|
|
113 place comment block with TAG (or those preceding
|
|
114 keyword lines) in output file. One TAG per argument
|
|
115 call
|
|
116
|
|
117
|
|
118 init
|
|
119 ====
|
|
120
|
|
121 The `init` sub-command creates a new translations catalog based on a PO
|
|
122 template file::
|
|
123
|
|
124 $ pybabel init --help
|
|
125 usage: pybabel init [options]
|
323
|
126
|
263
|
127 create new message catalogs from a POT file
|
323
|
128
|
263
|
129 options:
|
323
|
130 -h, --help show this help message and exit
|
|
131 -D DOMAIN, --domain=DOMAIN
|
|
132 domain of PO file (default 'messages')
|
|
133 -i FILE, --input-file=FILE
|
|
134 name of the input file
|
|
135 -d DIR, --output-dir=DIR
|
|
136 path to output directory
|
|
137 -o FILE, --output-file=FILE
|
|
138 name of the output file (default
|
|
139 '<output_dir>/<locale>/LC_MESSAGES/<domain>.po')
|
|
140 -l LOCALE, --locale=LOCALE
|
|
141 locale for the new localized catalog
|
263
|
142
|
|
143
|
|
144 update
|
|
145 ======
|
|
146
|
|
147 The `update` sub-command updates an existing new translations catalog based on
|
|
148 a PO template file::
|
|
149
|
|
150 $ pybabel update --help
|
|
151 usage: pybabel update [options]
|
323
|
152
|
263
|
153 update existing message catalogs from a POT file
|
323
|
154
|
263
|
155 options:
|
|
156 -h, --help show this help message and exit
|
|
157 -D DOMAIN, --domain=DOMAIN
|
|
158 domain of PO file (default 'messages')
|
|
159 -i FILE, --input-file=FILE
|
|
160 name of the input file
|
|
161 -d DIR, --output-dir=DIR
|
|
162 path to output directory
|
|
163 -o FILE, --output-file=FILE
|
|
164 name of the output file (default
|
|
165 '<output_dir>/<locale>/LC_MESSAGES/<domain>.po')
|
|
166 -l LOCALE, --locale=LOCALE
|
|
167 locale of the translations catalog
|
|
168 --ignore-obsolete do not include obsolete messages in the output
|
|
169 (default False)
|
323
|
170 -N, --no-fuzzy-matching
|
|
171 do not use fuzzy matching (default False)
|
|
172 --previous keep previous msgids of translated messages (default
|
|
173 False)
|
263
|
174
|
|
175 If ``output_dir`` is specified, but ``output-file`` is not, the default
|
|
176 filename of the output file will be::
|
|
177
|
|
178 <directory>/<locale>/LC_MESSAGES/<domain>.mo
|
|
179
|
|
180 If neither the ``output_file`` nor the ``locale`` option is set, this command
|
|
181 looks for all catalog files in the base directory that match the given domain,
|
|
182 and updates each of them.
|