Back to index

python3.2  3.2.2
Classes | Namespaces | Functions | Variables File Reference

Go to the source code of this file.


class  pygettext.TokenEater


namespace  pygettext


def pygettext.usage
def pygettext.make_escapes
def pygettext.escape
def pygettext.safe_eval
def pygettext.normalize
def pygettext.containsAny
def pygettext._visit_pyfiles
def pygettext._get_modpkg_path
def pygettext.getFilesForName
def pygettext.__waiting
 import token print >> sys.stderr, 'ttype:', token.tok_name[ttype], \ 'tstring:', tstring
def pygettext.__suiteseen
def pygettext.__suitedocstring
def pygettext.__keywordseen
def pygettext.__openseen
def pygettext.__addentry
def pygettext.set_filename
def pygettext.write
def pygettext.main


 pygettext._ = fintl.gettext
tuple pygettext.__doc__ = _("""pygettext -- Python equivalent of xgettext(1)Many systems (Solaris, Linux, Gnu) provide extensive tools that ease theinternationalization of C programs. Most of these tools are independent ofthe programming language and can be used from within Python programs.Martin von Loewis' work[1] helps considerably in this regard.There's one problem though; xgettext is the program that scans source codelooking for message strings, but it groks only C (or C++). Pythonintroduces a few wrinkles, such as dual quoting characters, triple quotedstrings, and raw strings. xgettext understands none of this.Enter pygettext, which uses Python's standard tokenize module to scanPython source code, generating .pot files identical to what GNU xgettext[2]generates for C and C++ code. From there, the standard GNU tools can beused.A word about marking Python strings as candidates for translation. GNUxgettext recognizes the following keywords: gettext, dgettext, dcgettext,and gettext_noop. But those can be a lot of text to include all over yourcode. C and C++ have a trick: they use the C preprocessor. Mostinternationalized C source includes a #define for gettext() to _() so thatwhat has to be written in the source is much less. Thus these are bothtranslatable strings: gettext("Translatable String") _("Translatable String")Python of course has no preprocessor so this doesn't work so well. Thus,pygettext searches only for _() by default, but see the -k/--keyword flagbelow for how to augment this. [1] [2] pygettext attempts to be option and feature compatible with GNUxgettext where ever possible. However some options are still missing or arenot fully implemented. Also, xgettext's use of command line switches withoption arguments is broken, and in these cases, pygettext just definesadditional switches.Usage: pygettext [options] inputfile ...Options: -a --extract-all Extract all strings. -d name --default-domain=name Rename the default output file from messages.pot to name.pot. -E --escape Replace non-ASCII characters with octal escape sequences. -D --docstrings Extract module, class, method, and function docstrings. These do not need to be wrapped in _() markers, and in fact cannot be for Python to consider them docstrings. (See also the -X option). -h --help Print this help message and exit. -k word --keyword=word Keywords to look for in addition to the default set, which are: %(DEFAULTKEYWORDS)s You can have multiple -k flags on the command line. -K --no-default-keywords Disable the default set of keywords (see above). Any keywords explicitly added with the -k/--keyword option are still recognized. --no-location Do not write filename/lineno location comments. -n --add-location Write filename/lineno location comments indicating where each extracted string is found in the source. These lines appear before each msgid. The style of comments is controlled by the -S/--style option. This is the default. -o filename --output=filename Rename the default output file from messages.pot to filename. If filename is `-' then the output is sent to standard out. -p dir --output-dir=dir Output files will be placed in directory dir. -S stylename --style stylename Specify which style to use for location comments. Two styles are supported: Solaris # File: filename, line: line-number GNU #: filename:line The style name is case insensitive. GNU style is the default. -v --verbose Print the names of the files being processed. -V --version Print the version of pygettext and exit. -w columns --width=columns Set width of output to columns. -x filename --exclude-file=filename Specify a file that contains a list of strings that are not be extracted from the input files. Each string to be excluded must appear on a line by itself in the file. -X filename --no-docstrings=filename Specify a file that contains a list of files (one per line) that should not have their docstrings extracted. This is only useful in conjunction with the -D option above.If `inputfile' is -, standard input is read.""")
string pygettext.__version__ = '1.5'
list pygettext.default_keywords = ['_']
string pygettext.DEFAULTKEYWORDS = ', '
string pygettext.EMPTYSTRING = ''
tuple pygettext.pot_header
list pygettext.escapes = []