PYGETTEXT(1)
okay bestie, this is PYGETTEXT(1) from the General Commands Manual ๐ ๐
๐ NAME
pygettext is the Python version of xgettext(1). Same energy, different language โจ
๐ง SYNOPSIS
pygettext [OPTIONS] INPUTFILE ...
๐ DESCRIPTION
real talk: pygettext is deprecated ๐ The current version of xgettext supports tons of languages, Python included, so use that one instead.
Okay so pygettext uses Python's standard tokenize module to scan your Python source code ๐ฆ It makes .pot files that are identical to what GNU xgettext makes for C and C++ code. Once you have those, the standard GNU tools are all yours to use ๐ซถ
Here's a lowkey important detail ๐ pygettext only searches for _() by default, even though GNU xgettext recognizes these keywords: gettext, dgettext, dcgettext, and gettext_noop. If you want more keywords in the mix, check out the -k/--keyword flag below โจ
๐ OPTIONS
-a,--extract-allโ Extract all the strings ๐-d,--default-domain=NAMEโ Rename the default output file frommessages.pottoname.pot๐ธ-E,--escapeโ Swap out non-ASCII characters for octal escape sequences ๐-D,--docstringsโ Extract module, class, method, and function docstrings โจ These don't need to be wrapped in_()markers, and honestly they can't be, or Python won't treat them as docstrings ๐ (Also see the-Xoption.)-h,--helpโ Print the help message and exit ๐-k,--keyword=WORDโ Add keywords to look for, on top of the default set, which is just_๐
You can have multiple -k flags on the command line, so go wild ๐
-K,--no-default-keywordsโ Turn off the default set of keywords (see above) ๐ Any keywords you added with-k/--keywordstill get recognized โจ--no-locationโ Don't writefilename/linenolocation comments ๐-n,--add-locationโ Writefilename/linenolocation comments that show where each extracted string lives in the source ๐ฆ These lines show up right before eachmsgid. The comment style is controlled by the-S/--styleoption. This one is the default, so it's giving main character ๐-o,--output=FILENAMEโ Rename the default output file frommessages.pottoFILENAME๐ IfFILENAMEis-, the output gets sent to standard out ๐-p,--output-dir=DIRโ Your output files will land in the directoryDIR๐ง-S,--style=STYLENAMEโ Pick which style to use for location comments ๐ธ Two styles are supported:- Solaris โ
# File: filename, line: line-number - GNU โ
#: filename:line
- Solaris โ
The style name is case insensitive, so don't stress ๐ GNU style is the default โจ
-v,--verboseโ Print the names of the files being processed as they go ๐-V,--versionโ Print the version ofpygettextand exit ๐ฅ-w,--width=COLUMNSโ Set the width of the output toCOLUMNS๐-x,--exclude-file=FILENAMEโ Point to a file that holds a list of strings that should NOT be extracted from your input files ๐ โโ๏ธ Each excluded string has to sit on its own line in that file, no sharing ๐-X,--no-docstrings=FILENAMEโ Point to a file that lists files (one per line) whose docstrings should NOT get extracted ๐ฆ This only matters together with the-Doption above ๐ซถ
If INPUTFILE is -, standard input gets read instead ๐ง
๐ BUGS
Okay, so pygettext tries really hard to stay compatible with GNU xgettext, option-wise and feature-wise, wherever it's possible โจ Some options are still missing or not fully implemented though, so heads up ๐ Also, xgettext uses command line switches with option arguments in a way that's broken, so in those cases pygettext just defines extra switches of its own ๐ซ
๐ฆ AUTHOR
pygettext is written by Barry Warsaw <barry@zope.com> ๐
Joonas Paalasmaa <joonas.paalasmaa@iki.fi> put this manual page together based on "pygettext --help" ๐ซถ๐
bestie, you're officially a pygettext pro now ๐๐ โจ
pygettext 1.4 ยท PYGETTEXT(1) โ stay cute, stay compiling ๐๐ง๐
๐ฆ where this page comes from
- ubuntu questing: python3.14 3.14.0-1
- ubuntu questing: python3.14 3.14.0-1ubuntu0.3
- ubuntu resolute: python3.14 3.14.4-1
- ubuntu resolute: python3.14 3.14.4-1ubuntu0.2
- ubuntu stonking: python3.14 3.14.8-1ubuntu1
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms