annotate doc/setup.txt @ 57:d930a3dfbf3d trunk

* The `extract_messages` distutils command now operators on configurable input directories again, instead of the complete current directory. The `input_dirs` default to the package directories. * Add a pseudo extractor called ?ignore? for #10.
author cmlenz
date Fri, 08 Jun 2007 11:28:15 +0000
parents 7dbcbc3f07e0
children 2df27f49c320
rev   line source
2
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
1 .. -*- mode: rst; encoding: utf-8 -*-
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
2
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
3 ================================
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
4 Distutils/Setuptools Integration
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
5 ================================
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
6
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
7 Babel provides commands for integration into ``setup.py`` scripts, based on
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
8 either the ``distutils`` package that is part of the Python standard library,
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
9 or the third-party ``setuptools`` package.
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
10
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
11 These commands are available by default when Babel has been properly installed,
20896f1e91c6 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
0739bc8e7210 Syntax highlighting for the docs.
cmlenz
parents: 2
diff changeset
13 ``distutils``, the commands need to be registered explicitly, for example:
0739bc8e7210 Syntax highlighting for the docs.
cmlenz
parents: 2
diff changeset
14
0739bc8e7210 Syntax highlighting for the docs.
cmlenz
parents: 2
diff changeset
15 .. code-block:: python
2
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
16
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
17 from distutils.core import setup
54
7dbcbc3f07e0 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
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
19
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
20 setup(
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
21 ...
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
22 cmd_class = {'extract_messages': babel.extract_messages}
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
23 )
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
24
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
25
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
26 .. contents:: Contents
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
27 :depth: 2
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
28 .. sectnum::
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
29
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
30
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
31 extract_messages
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
32 ================
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
33
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
34 The ``extract_messages`` command is comparabe to the GNU ``xgettext`` program:
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
35 it can extract localizable messages from a variety of difference source files,
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
36 and generate a PO (portable object) template file from the collected messages.
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
37
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
38 If the command has been correctly installed or registered, another project's
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
39 ``setup.py`` script should allow you to use the command::
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
40
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
41 $ ./setup.py extract_messages --help
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
42 Global options:
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
43 --verbose (-v) run verbosely (default)
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
44 --quiet (-q) run quietly (turns verbosity off)
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
45 --dry-run (-n) don't actually do anything
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
46 --help (-h) show detailed help message
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
47
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
48 Options for 'extract_messages' command:
49
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
49 --charset charset to use in the output file
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
50 --keywords (-k) space-separated list of keywords to look for in
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
51 addition to the defaults
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
52 --no-default-keywords do not include the default keywords
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
53 --mapping-file (-F) path to the mapping configuration file
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
54 --no-location do not include location comments with filename and
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
55 line number
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
56 --omit-header do not include msgid "" entry in header
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
57 --output-file (-o) name of the output file
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
58 --width (-w) set output line width (default 76)
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
59 --no-wrap do not break long message lines, longer than the
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
60 output line width, into several lines
2
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
61
51
d484eb9a70d5 Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents: 49
diff changeset
62 Running the command will produce a PO template file::
2
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
63
49
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
64 $ ./setup.py extract_messages --output-file foobar/locale/messages.pot
2
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
65 running extract_messages
49
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
66 extracting messages from foobar/__init__.py
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
67 extracting messages from foobar/core.py
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
68 ...
51
d484eb9a70d5 Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents: 49
diff changeset
69 writing PO template file to foobar/locale/messages.pot
49
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
70
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
71
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
72 Method Mapping
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
73 --------------
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
74
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
75 The mapping of file patterns to extraction methods (and options) can be
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
76 specified using a configuration file that is pointed to using the
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
77 ``--mapping-file`` option shown above. Alternatively, you can configure the
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
78 mapping directly in ``setup.py`` using a keyword argument to the ``setup()``
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
79 function:
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
80
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
81 .. code-block:: python
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
82
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
83 setup(...
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
84
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
85 message_extractors = {
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
86 'foobar/**.py': ('python', None),
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
87 'foobar/**/templates/**.html': ('genshi', None),
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
88 'foobar/**/templates/**.txt': ('genshi', {
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
89 'template_class': 'genshi.template.text.TextTemplate'
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
90 })
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
91 },
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
92
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
93 ...
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
94 )
2
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
95
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
96
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
97 Options
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
98 -------
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
99
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
100 As shown in the ``--help`` output above, the ``extract_messages`` command
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
101 accepts the following options:
20896f1e91c6 Forgot to check in the doc directory.
cmlenz
parents:
diff changeset
102
49
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
103 +-----------------------------+----------------------------------------------+
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
104 | Option | Description |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
105 +=============================+==============================================+
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
106 | ``--charset`` | charset to use in the output file |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
107 +-----------------------------+----------------------------------------------+
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
108 | ``--keywords`` (``-k``) | space-separated list of keywords to look for |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
109 | | in addition to the defaults |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
110 +-----------------------------+----------------------------------------------+
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
111 | ``--no-default-keywords`` | do not include the default keywords |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
112 +-----------------------------+----------------------------------------------+
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
113 | ``--mapping-file`` (``-F``) | path to the mapping configuration file |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
114 +-----------------------------+----------------------------------------------+
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
115 | ``--no-location`` | do not include location comments with |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
116 | | filename and line number |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
117 +-----------------------------+----------------------------------------------+
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
118 | ``--omit-header`` | do not include msgid "" entry in header |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
119 +-----------------------------+----------------------------------------------+
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
120 | ``--output-file`` (``-o``) | name of the output file |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
121 +-----------------------------+----------------------------------------------+
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
122 | ``--width`` (``-w``) | set output line width (default 76) |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
123 +-----------------------------+----------------------------------------------+
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
124 | ``--no-wrap`` | do not break long message lines, longer than |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
125 | | the output line width, into several lines |
37bd476dafe4 Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents: 40
diff changeset
126 +-----------------------------+----------------------------------------------+
Copyright (C) 2012-2017 Edgewall Software