When properly installed, Babel provides a script called ``pybabel``::
- $ pybabel --help
- usage: pybabel subcommand [options] [args]
+ $ pybabel --help
+ usage: pybabel command [options] [args]
options:
- --version show program's version number and exit
- -h, --help show this help message and exit
-
- subcommands:
- compile compile message catalogs to MO files
- extract extract messages from source files and generate a POT file
- init create new message catalogs from a POT file
- update update existing message catalogs from a POT file
+ --version show program's version number and exit
+ -h, --help show this help message and exit
+ --list-locales print all known locales and exit
+ -v, --verbose print as much as possible
+ -q, --quiet print as little as possible
+
+ commands:
+ compile compile message catalogs to MO files
+ extract extract messages from source files and generate a POT file
+ init create new message catalogs from a POT file
+ update update existing message catalogs from a POT file
The ``pybabel`` script provides a number of sub-commands that do the actual
work. Those sub-commands are described below.
$ pybabel compile --help
usage: pybabel compile [options]
-
+
compile message catalogs to MO files
-
+
options:
-h, --help show this help message and exit
-D DOMAIN, --domain=DOMAIN
name of the output file (default
'<output_dir>/<locale>/LC_MESSAGES/<domain>.mo')
-f, --use-fuzzy also include fuzzy translations (default False)
+ --statistics print statistics about translations
If ``directory`` is specified, but ``output-file`` is not, the default filename
of the output file will be::
and compiles each of them to MO files in the same directory.
-
extract
=======
$ pybabel extract --help
usage: pybabel extract [options] dir1 <dir2> ...
-
+
extract messages from source files and generate a POT file
-
+
options:
-h, --help show this help message and exit
- --charset=CHARSET charset to use in the output
+ --charset=CHARSET charset to use in the output (default "utf-8")
-k KEYWORDS, --keyword=KEYWORDS
keywords to look for in addition to the defaults. You
can specify multiple -k flags on the command line.
$ pybabel init --help
usage: pybabel init [options]
-
+
create new message catalogs from a POT file
-
+
options:
- -h, --help show this help message and exit
- -D DOMAIN, --domain=DOMAIN
- domain of PO file (defaults to lower-cased project
- name)
- -i INPUT_FILE, --input-file=INPUT_FILE
- name of the input file
- -d OUTPUT_DIR, --output-dir=OUTPUT_DIR
- path to output directory
- -o OUTPUT_FILE, --output-file=OUTPUT_FILE
- name of the output file (default
- '<output_dir>/<locale>/<domain>.po')
- -l LOCALE, --locale=LOCALE
- locale for the new localized catalog
- --first-author=FIRST_AUTHOR_NAME
- name of first author
- --first-author-email=FIRST_AUTHOR_EMAIL
- email of first author
- --project-name=NAME the project name
- --project-version=VERSION
- the project version
+ -h, --help show this help message and exit
+ -D DOMAIN, --domain=DOMAIN
+ domain of PO file (default 'messages')
+ -i FILE, --input-file=FILE
+ name of the input file
+ -d DIR, --output-dir=DIR
+ path to output directory
+ -o FILE, --output-file=FILE
+ name of the output file (default
+ '<output_dir>/<locale>/LC_MESSAGES/<domain>.po')
+ -l LOCALE, --locale=LOCALE
+ locale for the new localized catalog
update
$ pybabel update --help
usage: pybabel update [options]
-
+
update existing message catalogs from a POT file
-
+
options:
-h, --help show this help message and exit
-D DOMAIN, --domain=DOMAIN
locale of the translations catalog
--ignore-obsolete do not include obsolete messages in the output
(default False)
+ -N, --no-fuzzy-matching
+ do not use fuzzy matching (default False)
+ --previous keep previous msgids of translated messages (default
+ False)
If ``output_dir`` is specified, but ``output-file`` is not, the default
filename of the output file will be::
The ``compile_catalog`` command accepts the following options:
- +-----------------------------+----------------------------------------------+
- | Option | Description |
- +=============================+==============================================+
- | ``--domain`` | domain of the PO file (defaults to |
- | | lower-cased project name) |
- +-----------------------------+----------------------------------------------+
- | ``--directory`` (``-d``) | name of the base directory |
- +-----------------------------+----------------------------------------------+
- | ``--input-file`` (``-i``) | name of the input file |
- +-----------------------------+----------------------------------------------+
- | ``--output-file`` (``-o``) | name of the output file |
- +-----------------------------+----------------------------------------------+
- | ``--locale`` | locale for the new localized string |
- +-----------------------------+----------------------------------------------+
- | ``--use-fuzzy`` | also include "fuzzy" translations |
- +-----------------------------+----------------------------------------------+
+ +-----------------------------+---------------------------------------------+
+ | Option | Description |
+ +=============================+=============================================+
+ | ``--domain`` | domain of the PO file (defaults to |
+ | | lower-cased project name) |
+ +-----------------------------+---------------------------------------------+
+ | ``--directory`` (``-d``) | name of the base directory |
+ +-----------------------------+---------------------------------------------+
+ | ``--input-file`` (``-i``) | name of the input file |
+ +-----------------------------+---------------------------------------------+
+ | ``--output-file`` (``-o``) | name of the output file |
+ +-----------------------------+---------------------------------------------+
+ | ``--locale`` (``-l``) | locale for the new localized string |
+ +-----------------------------+---------------------------------------------+
+ | ``--use-fuzzy`` (``-f``) | also include "fuzzy" translations |
+ +-----------------------------+---------------------------------------------+
+ | ``--statistics`` | print statistics about translations |
+ +-----------------------------+---------------------------------------------+
If ``directory`` is specified, but ``output-file`` is not, the default filename
of the output file will be::
The ``init_catalog`` command accepts the following options:
- +-----------------------------+----------------------------------------------+
- | Option | Description |
- +=============================+==============================================+
- | ``--domain`` | domain of the PO file (defaults to |
- | | lower-cased project name) |
- +-----------------------------+----------------------------------------------+
- | ``--input-file`` (``-i``) | name of the input file |
- +-----------------------------+----------------------------------------------+
- | ``--output-dir`` (``-d``) | name of the output directory |
- +-----------------------------+----------------------------------------------+
- | ``--output-file`` (``-o``) | name of the output file |
- +-----------------------------+----------------------------------------------+
- | ``--locale`` | locale for the new localized string |
- +-----------------------------+----------------------------------------------+
- | ``--omit-header`` | do not include msgid "" entry in header |
- +-----------------------------+----------------------------------------------+
- | ``--first-author`` | name of the first author |
- +-----------------------------+----------------------------------------------+
- | ``--first-author-email`` | email address of the first author |
- +-----------------------------+----------------------------------------------+
+ +-----------------------------+---------------------------------------------+
+ | Option | Description |
+ +=============================+=============================================+
+ | ``--domain`` | domain of the PO file (defaults to |
+ | | lower-cased project name) |
+ +-----------------------------+---------------------------------------------+
+ | ``--input-file`` (``-i``) | name of the input file |
+ +-----------------------------+---------------------------------------------+
+ | ``--output-dir`` (``-d``) | name of the output directory |
+ +-----------------------------+---------------------------------------------+
+ | ``--output-file`` (``-o``) | name of the output file |
+ +-----------------------------+---------------------------------------------+
+ | ``--locale`` | locale for the new localized string |
+ +-----------------------------+---------------------------------------------+
If ``output-dir`` is specified, but ``output-file`` is not, the default filename
of the output file will be::
The ``update_catalog`` command accepts the following options:
- +-----------------------------+----------------------------------------------+
- | Option | Description |
- +=============================+==============================================+
- | ``--domain`` | domain of the PO file (defaults to |
- | | lower-cased project name) |
- +-----------------------------+----------------------------------------------+
- | ``--input-file`` (``-i``) | name of the input file |
- +-----------------------------+----------------------------------------------+
- | ``--output-dir`` (``-d``) | name of the output directory |
- +-----------------------------+----------------------------------------------+
- | ``--output-file`` (``-o``) | name of the output file |
- +-----------------------------+----------------------------------------------+
- | ``--locale`` | locale for the new localized string |
- +-----------------------------+----------------------------------------------+
- | ``--ignore-obsolete`` | do not include obsolete messages in the |
- | | output |
- +-----------------------------+----------------------------------------------+
+ +-------------------------------------+-------------------------------------+
+ | Option | Description |
+ +=====================================+=====================================+
+ | ``--domain`` | domain of the PO file (defaults to |
+ | | lower-cased project name) |
+ +-------------------------------------+-------------------------------------+
+ | ``--input-file`` (``-i``) | name of the input file |
+ +-------------------------------------+-------------------------------------+
+ | ``--output-dir`` (``-d``) | name of the output directory |
+ +-------------------------------------+-------------------------------------+
+ | ``--output-file`` (``-o``) | name of the output file |
+ +-------------------------------------+-------------------------------------+
+ | ``--locale`` | locale for the new localized string |
+ +-------------------------------------+-------------------------------------+
+ | ``--ignore-obsolete`` | do not include obsolete messages in |
+ | | the output |
+ +-------------------------------------+-------------------------------------+
+ | ``--no-fuzzy-matching`` (``-N``) | do not use fuzzy matching |
+ +-------------------------------------+-------------------------------------+
+ | ``--previous`` | keep previous msgids of translated |
+ | | messages |
+ +-------------------------------------+-------------------------------------+
If ``output-dir`` is specified, but ``output-file`` is not, the default filename
of the output file will be::