PYGETTEXT(1)

๐Ÿ“ฆ version 3.10.12, in ubuntu jammy

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 from messages.pot to name.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 -X option.)
  • -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/--keyword still get recognized โœจ
  • --no-location โ€” Don't write filename/lineno location comments ๐Ÿ™ˆ
  • -n, --add-location โ€” Write filename/lineno location comments that show where each extracted string lives in the source ๐Ÿฆ‹ These lines show up right before each msgid. The comment style is controlled by the -S/--style option. This one is the default, so it's giving main character ๐Ÿ‘‘
  • -o, --output=FILENAME โ€” Rename the default output file from messages.pot to FILENAME ๐ŸŽ€ If FILENAME is -, the output gets sent to standard out ๐Ÿ’…
  • -p, --output-dir=DIR โ€” Your output files will land in the directory DIR ๐Ÿงš
  • -S, --style=STYLENAME โ€” Pick 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, 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 of pygettext and exit ๐Ÿ”ฅ
  • -w, --width=COLUMNS โ€” Set the width of the output to COLUMNS ๐ŸŒˆ
  • -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 -D option 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