annotate doc/setup.txt @ 175:3c4718fb7435

Changed the `__repr__` output to include the flags(it can be changed back, but it was usefull to implement the fuzzy header parsing). The `Catalog` class now also includes an extra attribute, '''`fuzzy`''', which is the fuzzy bit of the catalog header. The above change allows the `compile_catalog` frontends to only compile catalogs '''not''' marked as fuzzy, unless `--use-fuzzy` is passed. Added tests to check header fuzzy bit parsing.
author palgarvio
date Tue, 26 Jun 2007 16:46:56 +0000
parents 80e51aabc440
children a7766f92f944
rev   line source
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
1 .. -*- mode: rst; encoding: utf-8 -*-
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
3 ================================
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
4 Distutils/Setuptools Integration
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
5 ================================
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
6
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
7 Babel provides commands for integration into ``setup.py`` scripts, based on
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
8 either the ``distutils`` package that is part of the Python standard library,
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
9 or the third-party ``setuptools`` package.
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
10
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
11 These commands are available by default when Babel has been properly installed,
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
12 and ``setup.py`` is using ``setuptools``. For projects that use plain old
40
4525549aa6cc Syntax highlighting for the docs.
cmlenz
parents: 2
diff changeset
13 ``distutils``, the commands need to be registered explicitly, for example:
4525549aa6cc Syntax highlighting for the docs.
cmlenz
parents: 2
diff changeset
14
4525549aa6cc Syntax highlighting for the docs.
cmlenz
parents: 2
diff changeset
15 .. code-block:: python
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
16
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
17 from distutils.core import setup
54
b3395b285104 Rename the `babel.catalog` package to `babel.messages` for consistency with the other package names.
cmlenz
parents: 51
diff changeset
18 from babel.messages import frontend as babel
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
19
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
20 setup(
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
21 ...
160
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
22 cmd_class = {'compile_catalog': babel.compile_catalog,
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
23 'extract_messages': babel.extract_messages,
90
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
24 'new_catalog': babel.new_catalog}
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
25 )
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
26
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
27
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
28 .. contents:: Contents
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
29 :depth: 2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
30 .. sectnum::
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
31
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
32
160
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
33 compile_catalog
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
34 ===============
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
35
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
36 The ``compile_catalog`` command is similar to the GNU ``msgfmt`` tool, in that
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
37 it takes a message catalog from a PO file and compiles it to a binary MO file.
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
38
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
39 If the command has been correctly installed or registered, a project's
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
40 ``setup.py`` script should allow you to use the command::
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
41
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
42 $ ./setup.py compile_catalog --help
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
43 Global options:
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
44 --verbose (-v) run verbosely (default)
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
45 --quiet (-q) run quietly (turns verbosity off)
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
46 --dry-run (-n) don't actually do anything
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
47 --help (-h) show detailed help message
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
48
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
49 Options for 'compile_catalog' command:
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
50 ...
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
51
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
52 Running the command will produce a PO template file::
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
53
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
54 $ ./setup.py compile_catalog --directory foobar/locale --locale pt_BR
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
55 running compile_catalog
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
56 compiling catalog to to foobar/locale/pt_BR/LC_MESSAGES/messages.mo
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
57
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
58
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
59 Options
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
60 -------
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
61
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
62 The ``compile_catalog`` command accepts the following options:
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
63
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
64 +-----------------------------+----------------------------------------------+
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
65 | Option | Description |
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
66 +=============================+==============================================+
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
67 | ``--domain`` | domain of the PO file (defaults to |
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
68 | | lower-cased project name) |
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
69 +-----------------------------+----------------------------------------------+
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
70 | ``--directory`` (``-d``) | name of the base directory |
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
71 +-----------------------------+----------------------------------------------+
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
72 | ``--input-file`` (``-i``) | name of the input file |
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
73 +-----------------------------+----------------------------------------------+
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
74 | ``--output-file`` (``-o``) | name of the output file |
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
75 +-----------------------------+----------------------------------------------+
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
76 | ``--locale`` | locale for the new localized string |
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
77 +-----------------------------+----------------------------------------------+
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
78 | ``--use-fuzzy`` | also include "fuzzy" translations |
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
79 +-----------------------------+----------------------------------------------+
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
80
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
81 If ``directory`` is specified, but ``output-file`` is not, the default filename
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
82 of the output file will be::
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
83
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
84 <output_dir>/<locale>/LC_MESSAGES/<domain>.mo
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
85
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
86 These options can either be specified on the command-line, or in the
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
87 ``setup.cfg`` file.
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
88
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
89
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
90 extract_messages
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
91 ================
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
92
90
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
93 The ``extract_messages`` command is comparable to the GNU ``xgettext`` program:
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
94 it can extract localizable messages from a variety of difference source files,
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
95 and generate a PO (portable object) template file from the collected messages.
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
96
160
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
97 If the command has been correctly installed or registered, a project's
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
98 ``setup.py`` script should allow you to use the command::
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
99
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
100 $ ./setup.py extract_messages --help
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
101 Global options:
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
102 --verbose (-v) run verbosely (default)
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
103 --quiet (-q) run quietly (turns verbosity off)
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
104 --dry-run (-n) don't actually do anything
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
105 --help (-h) show detailed help message
77
5c819411e4af Updated frontend screens for added sorting features.
cmlenz
parents: 62
diff changeset
106
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
107 Options for 'extract_messages' command:
90
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
108 ...
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
109
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents: 49
diff changeset
110 Running the command will produce a PO template file::
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
111
49
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
112 $ ./setup.py extract_messages --output-file foobar/locale/messages.pot
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
113 running extract_messages
49
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
114 extracting messages from foobar/__init__.py
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
115 extracting messages from foobar/core.py
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
116 ...
51
7f61453c1bea Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents: 49
diff changeset
117 writing PO template file to foobar/locale/messages.pot
49
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
118
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
119
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
120 Method Mapping
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
121 --------------
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
122
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
123 The mapping of file patterns to extraction methods (and options) can be
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
124 specified using a configuration file that is pointed to using the
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
125 ``--mapping-file`` option shown above. Alternatively, you can configure the
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
126 mapping directly in ``setup.py`` using a keyword argument to the ``setup()``
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
127 function:
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
128
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
129 .. code-block:: python
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
130
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
131 setup(...
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
132
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
133 message_extractors = {
62
84d400066b71 The order of extraction methods is now preserved (see #10).
cmlenz
parents: 54
diff changeset
134 'foobar': [
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 90
diff changeset
135 ('**.py', 'python', None),
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 90
diff changeset
136 ('**/templates/**.html', 'genshi', None),
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 90
diff changeset
137 ('**/templates/**.txt', 'genshi', {
144
a5914ba672d1 Some doc fixes.
cmlenz
parents: 117
diff changeset
138 'template_class': 'genshi.template:TextTemplate'
62
84d400066b71 The order of extraction methods is now preserved (see #10).
cmlenz
parents: 54
diff changeset
139 })
84d400066b71 The order of extraction methods is now preserved (see #10).
cmlenz
parents: 54
diff changeset
140 ],
49
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
141 },
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
142
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
143 ...
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
144 )
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
145
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
146
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
147 Options
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
148 -------
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
149
90
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
150 The ``extract_messages`` command accepts the following options:
2
b2492365f186 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
151
49
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
152 +-----------------------------+----------------------------------------------+
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
153 | Option | Description |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
154 +=============================+==============================================+
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
155 | ``--charset`` | charset to use in the output file |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
156 +-----------------------------+----------------------------------------------+
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
157 | ``--keywords`` (``-k``) | space-separated list of keywords to look for |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
158 | | in addition to the defaults |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
159 +-----------------------------+----------------------------------------------+
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
160 | ``--no-default-keywords`` | do not include the default keywords |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
161 +-----------------------------+----------------------------------------------+
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
162 | ``--mapping-file`` (``-F``) | path to the mapping configuration file |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
163 +-----------------------------+----------------------------------------------+
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
164 | ``--no-location`` | do not include location comments with |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
165 | | filename and line number |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
166 +-----------------------------+----------------------------------------------+
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
167 | ``--omit-header`` | do not include msgid "" entry in header |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
168 +-----------------------------+----------------------------------------------+
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
169 | ``--output-file`` (``-o``) | name of the output file |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
170 +-----------------------------+----------------------------------------------+
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
171 | ``--width`` (``-w``) | set output line width (default 76) |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
172 +-----------------------------+----------------------------------------------+
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
173 | ``--no-wrap`` | do not break long message lines, longer than |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
174 | | the output line width, into several lines |
daf35e2ad044 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
175 +-----------------------------+----------------------------------------------+
62
84d400066b71 The order of extraction methods is now preserved (see #10).
cmlenz
parents: 54
diff changeset
176 | ``--input-dirs`` | directories that should be scanned for |
84d400066b71 The order of extraction methods is now preserved (see #10).
cmlenz
parents: 54
diff changeset
177 | | messages |
84d400066b71 The order of extraction methods is now preserved (see #10).
cmlenz
parents: 54
diff changeset
178 +-----------------------------+----------------------------------------------+
90
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
179 | ``--sort-output`` | generate sorted output (default False) |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
180 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
181 | ``--sort-by-file`` | sort output by file location (default False) |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
182 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
183 | ``--msgid-bugs-address`` | set email address for message bug reports |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
184 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
185 | ``--copyright-holder`` | set copyright holder in output |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
186 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
187 | ``--add-comments (-c)`` | place comment block with TAG (or those |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
188 | | preceding keyword lines) in output file. |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
189 | | Separate multiple TAGs with commas(,) |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
190 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
191
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
192 These options can either be specified on the command-line, or in the
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
193 ``setup.cfg`` file. In the latter case, the options above become entries of the
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
194 section ``[extract_messages]``, and the option names are changed to use
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
195 underscore characters instead of dashes, for example:
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
196
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
197 .. code-block:: ini
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
198
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
199 [extract_messages]
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
200 keywords = _, gettext, ngettext
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
201 mapping_file = babel.cfg
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
202 width = 80
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
203
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
204 This would be equivalent to invoking the command from the command-line as
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
205 follows::
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
206
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
207 $ setup.py extract_messages -k _ -k gettext -k ngettext -F mapping.cfg -w 80
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
208
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
209 Any path names are interpreted relative to the location of the ``setup.py``
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
210 file. For boolean options, use "true" or "false" values.
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
211
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
212
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
213 new_catalog
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
214 ===========
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
215
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
216 The ``new_catalog`` command is basically equivalent to the GNU ``msginit``
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
217 program: it creates a new translation catalog based on a PO template file (POT).
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
218
160
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 144
diff changeset
219 If the command has been correctly installed or registered, a project's
90
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
220 ``setup.py`` script should allow you to use the command::
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
221
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
222 $ ./setup.py new_catalog --help
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
223 Global options:
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
224 --verbose (-v) run verbosely (default)
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
225 --quiet (-q) run quietly (turns verbosity off)
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
226 --dry-run (-n) don't actually do anything
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
227 --help (-h) show detailed help message
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
228
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
229 Options for 'new_catalog' command:
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
230 ...
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
231
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
232 Running the command will produce a PO file::
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
233
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
234 $ ./setup.py new_catalog -l fr -i foobar/locales/messages.pot \
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
235 -o foobar/locales/fr/messages.po
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
236 running new_catalog
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
237 creating catalog 'foobar/locales/fr/messages.po' based on 'foobar/locales/messages.pot'
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
238
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
239
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
240 Options
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
241 -------
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
242
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
243 The ``new_catalog`` command accepts the following options:
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
244
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
245 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
246 | Option | Description |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
247 +=============================+==============================================+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
248 | ``--domain`` | domain of the PO file (defaults to |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
249 | | lower-cased project name) |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
250 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
251 | ``--input-file`` (``-i``) | name of the input file |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
252 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
253 | ``--output-dir`` (``-d``) | name of the output directory |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
254 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
255 | ``--output-file`` (``-o``) | name of the output file |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
256 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
257 | ``--locale`` | locale for the new localized string |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
258 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
259 | ``--omit-header`` | do not include msgid "" entry in header |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
260 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
261 | ``--first-author`` | name of the first author |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
262 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
263 | ``--first-author-email`` | email address of the first author |
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
264 +-----------------------------+----------------------------------------------+
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
265
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
266 If ``output-dir`` is specified, but ``output-file`` is not, the default filename
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
267 of the output file will be::
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
268
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
269 <output_dir>/<locale>/LC_MESSAGES/<domain>.po
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
270
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
271 These options can either be specified on the command-line, or in the
e43bb7dc7eec Some doc improvements on distutils integration.
cmlenz
parents: 80
diff changeset
272 ``setup.cfg`` file.
Copyright (C) 2012-2017 Edgewall Software