Mercurial > babel > old > babel-test
annotate doc/setup.txt @ 62:84d400066b71
The order of extraction methods is now preserved (see #10).
author | cmlenz |
---|---|
date | Fri, 08 Jun 2007 12:41:00 +0000 |
parents | b3395b285104 |
children | 5c819411e4af |
rev | line source |
---|---|
2 | 1 .. -*- mode: rst; encoding: utf-8 -*- |
2 | |
3 ================================ | |
4 Distutils/Setuptools Integration | |
5 ================================ | |
6 | |
7 Babel provides commands for integration into ``setup.py`` scripts, based on | |
8 either the ``distutils`` package that is part of the Python standard library, | |
9 or the third-party ``setuptools`` package. | |
10 | |
11 These commands are available by default when Babel has been properly installed, | |
12 and ``setup.py`` is using ``setuptools``. For projects that use plain old | |
40 | 13 ``distutils``, the commands need to be registered explicitly, for example: |
14 | |
15 .. code-block:: python | |
2 | 16 |
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 | 19 |
20 setup( | |
21 ... | |
22 cmd_class = {'extract_messages': babel.extract_messages} | |
23 ) | |
24 | |
25 | |
26 .. contents:: Contents | |
27 :depth: 2 | |
28 .. sectnum:: | |
29 | |
30 | |
31 extract_messages | |
32 ================ | |
33 | |
34 The ``extract_messages`` command is comparabe to the GNU ``xgettext`` program: | |
35 it can extract localizable messages from a variety of difference source files, | |
36 and generate a PO (portable object) template file from the collected messages. | |
37 | |
38 If the command has been correctly installed or registered, another project's | |
39 ``setup.py`` script should allow you to use the command:: | |
40 | |
41 $ ./setup.py extract_messages --help | |
42 Global options: | |
43 --verbose (-v) run verbosely (default) | |
44 --quiet (-q) run quietly (turns verbosity off) | |
45 --dry-run (-n) don't actually do anything | |
46 --help (-h) show detailed help message | |
47 | |
48 Options for 'extract_messages' command: | |
49
daf35e2ad044
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 |
daf35e2ad044
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 |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
51 addition to the defaults |
daf35e2ad044
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 |
daf35e2ad044
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 |
daf35e2ad044
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 |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
55 line number |
daf35e2ad044
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 |
daf35e2ad044
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 |
daf35e2ad044
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) |
daf35e2ad044
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 |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
60 output line width, into several lines |
62
84d400066b71
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
54
diff
changeset
|
61 --input-dirs directories that should be scanned for messages |
2 | 62 |
51
7f61453c1bea
Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
49
diff
changeset
|
63 Running the command will produce a PO template file:: |
2 | 64 |
49
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
65 $ ./setup.py extract_messages --output-file foobar/locale/messages.pot |
2 | 66 running extract_messages |
49
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
67 extracting messages from foobar/__init__.py |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
68 extracting messages from foobar/core.py |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
69 ... |
51
7f61453c1bea
Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
palgarvio
parents:
49
diff
changeset
|
70 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
|
71 |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
72 |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
73 Method Mapping |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
74 -------------- |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
75 |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
76 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
|
77 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
|
78 ``--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
|
79 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
|
80 function: |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
81 |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
82 .. code-block:: python |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
83 |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
84 setup(... |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
85 |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
86 message_extractors = { |
62
84d400066b71
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
54
diff
changeset
|
87 'foobar': [ |
84d400066b71
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
54
diff
changeset
|
88 ('**.py', ('python', None), |
84d400066b71
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
54
diff
changeset
|
89 ('**/templates/**.html', ('genshi', None), |
84d400066b71
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
54
diff
changeset
|
90 ('**/templates/**.txt', ('genshi', { |
84d400066b71
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
54
diff
changeset
|
91 'template_class': 'genshi.template.text.TextTemplate' |
84d400066b71
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
54
diff
changeset
|
92 }) |
84d400066b71
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
54
diff
changeset
|
93 ], |
49
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
94 }, |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
95 |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
96 ... |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
97 ) |
2 | 98 |
99 | |
100 Options | |
101 ------- | |
102 | |
103 As shown in the ``--help`` output above, the ``extract_messages`` command | |
104 accepts the following options: | |
105 | |
49
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
106 +-----------------------------+----------------------------------------------+ |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
107 | Option | Description | |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
108 +=============================+==============================================+ |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
109 | ``--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
|
110 +-----------------------------+----------------------------------------------+ |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
111 | ``--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
|
112 | | in addition to the defaults | |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
113 +-----------------------------+----------------------------------------------+ |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
114 | ``--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
|
115 +-----------------------------+----------------------------------------------+ |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
116 | ``--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
|
117 +-----------------------------+----------------------------------------------+ |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
118 | ``--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
|
119 | | filename and line number | |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
120 +-----------------------------+----------------------------------------------+ |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
121 | ``--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
|
122 +-----------------------------+----------------------------------------------+ |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
123 | ``--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
|
124 +-----------------------------+----------------------------------------------+ |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
125 | ``--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
|
126 +-----------------------------+----------------------------------------------+ |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
127 | ``--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
|
128 | | the output line width, into several lines | |
daf35e2ad044
Support a `message_extractors` keyword argument directly in `setup()`. Closes #4.
cmlenz
parents:
40
diff
changeset
|
129 +-----------------------------+----------------------------------------------+ |
62
84d400066b71
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
54
diff
changeset
|
130 | ``--input-dirs`` | directories that should be scanned for | |
84d400066b71
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
54
diff
changeset
|
131 | | messages | |
84d400066b71
The order of extraction methods is now preserved (see #10).
cmlenz
parents:
54
diff
changeset
|
132 +-----------------------------+----------------------------------------------+ |