{
    "mode": "man",
    "parameter": "XGETTEXT",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/XGETTEXT/1/json",
    "generated": "2026-06-14T07:28:33Z",
    "synopsis": "xgettext [OPTION] [INPUTFILE]...",
    "sections": {
        "NAME": {
            "content": "xgettext - extract gettext strings from source\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "xgettext [OPTION] [INPUTFILE]...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Extract translatable strings from given input files.\n\nMandatory  arguments  to long options are mandatory for short options too.  Similarly for op‐\ntional arguments.\n",
            "subsections": [
                {
                    "name": "Input file location:",
                    "content": "INPUTFILE ...\ninput files\n"
                },
                {
                    "name": "-f --files-from",
                    "content": "get list of input files from FILE\n",
                    "flag": "-f",
                    "long": "--files-from"
                },
                {
                    "name": "-D --directory",
                    "content": "add DIRECTORY to list for input files search\n\nIf input file is -, standard input is read.\n",
                    "flag": "-D",
                    "long": "--directory"
                },
                {
                    "name": "Output file location:",
                    "content": ""
                },
                {
                    "name": "-d --default-domain",
                    "content": "use NAME.po for output (instead of messages.po)\n",
                    "flag": "-d",
                    "long": "--default-domain"
                },
                {
                    "name": "-o --output",
                    "content": "write output to specified file\n",
                    "flag": "-o",
                    "long": "--output"
                },
                {
                    "name": "-p --output-dir",
                    "content": "output files will be placed in directory DIR\n\nIf output file is -, output is written to standard output.\n",
                    "flag": "-p",
                    "long": "--output-dir"
                },
                {
                    "name": "Choice of input file language:",
                    "content": ""
                },
                {
                    "name": "-L --language",
                    "content": "recognise the specified language (C, C++, ObjectiveC, PO, Shell, Python,  Lisp,  Emac‐\nsLisp,  librep, Scheme, Smalltalk, Java, JavaProperties, C#, awk, YCP, Tcl, Perl, PHP,\nRuby, GCC-source, NXStringTable, RST, RSJ, Glade, Lua, JavaScript, Vala, Desktop)\n",
                    "flag": "-L",
                    "long": "--language"
                },
                {
                    "name": "-C --c",
                    "content": "shorthand for --language=C++\n\nBy default the language is guessed depending on the input file name extension.\n",
                    "flag": "-C",
                    "long": "--c"
                },
                {
                    "name": "Input file interpretation:",
                    "content": "--from-code=NAME\nencoding of input files (except for Python, Tcl, Glade)\n\nBy default the input files are assumed to be in ASCII.\n"
                },
                {
                    "name": "Operation mode:",
                    "content": ""
                },
                {
                    "name": "-j --join-existing",
                    "content": "join messages with existing file\n",
                    "flag": "-j",
                    "long": "--join-existing"
                },
                {
                    "name": "-x --exclude-file",
                    "content": "entries from FILE.po are not extracted\n",
                    "flag": "-x",
                    "long": "--exclude-file"
                },
                {
                    "name": "-cTAG --add-comments",
                    "content": "place comment blocks starting with TAG and preceding keyword lines in output file\n",
                    "long": "--add-comments"
                },
                {
                    "name": "-c --add-comments",
                    "content": "place all comment blocks preceding keyword lines in output file\n\n--check=NAME\nperform syntax check on messages (ellipsis-unicode, space-ellipsis,\n\nquote-unicode, bullet-unicode)\n\n--sentence-end=TYPE\ntype describing the end of sentence (single-space, which is the default,\n\nor double-space)\n",
                    "flag": "-c",
                    "long": "--add-comments"
                },
                {
                    "name": "Language specific options:",
                    "content": ""
                },
                {
                    "name": "-a --extract-all",
                    "content": "extract all strings (only languages C, C++, ObjectiveC,  Shell,  Python,  Lisp,  Emac‐\nsLisp,  librep,  Scheme,  Java, C#, awk, Tcl, Perl, PHP, GCC-source, Glade, Lua, Java‐\nScript, Vala)\n",
                    "flag": "-a",
                    "long": "--extract-all"
                },
                {
                    "name": "-kWORD --keyword",
                    "content": "look for WORD as an additional keyword\n",
                    "long": "--keyword"
                },
                {
                    "name": "-k --keyword",
                    "content": "do not to use default keywords (only languages  C,  C++,  ObjectiveC,  Shell,  Python,\nLisp,  EmacsLisp,  librep,  Scheme,  Java, C#, awk, Tcl, Perl, PHP, GCC-source, Glade,\nLua, JavaScript, Vala, Desktop)\n\n--flag=WORD:ARG:FLAG\nadditional flag for strings inside the argument number ARG of keyword WORD\n\n(only languages C, C++, ObjectiveC, Shell,\nPython, Lisp,  EmacsLisp,  librep,  Scheme,  Java,  C#,  awk,  YCP,  Tcl,  Perl,  PHP,\nGCC-source, Lua, JavaScript, Vala)\n",
                    "flag": "-k",
                    "long": "--keyword"
                },
                {
                    "name": "-T --trigraphs",
                    "content": "understand ANSI C trigraphs for input (only languages C, C++, ObjectiveC)\n\n--its=FILE\napply ITS rules from FILE (only XML based languages)\n\n--qt   recognize Qt format strings (only language C++)\n\n--kde  recognize KDE 4 format strings (only language C++)\n",
                    "flag": "-T",
                    "long": "--trigraphs"
                },
                {
                    "name": "--boost",
                    "content": "recognize Boost format strings (only language C++)\n",
                    "long": "--boost"
                },
                {
                    "name": "--debug",
                    "content": "more detailed formatstring recognition result\n",
                    "long": "--debug"
                },
                {
                    "name": "Output details:",
                    "content": ""
                },
                {
                    "name": "--color",
                    "content": "use colors and other text attributes always\n\n--color=WHEN\nuse  colors and other text attributes if WHEN.  WHEN may be 'always', 'never', 'auto',\nor 'html'.\n\n--style=STYLEFILE\nspecify CSS style rule file for --color\n",
                    "long": "--color"
                },
                {
                    "name": "-e --no-escape",
                    "content": "do not use C escapes in output (default)\n",
                    "flag": "-e",
                    "long": "--no-escape"
                },
                {
                    "name": "-E --escape",
                    "content": "use C escapes in output, no extended chars\n",
                    "flag": "-E",
                    "long": "--escape"
                },
                {
                    "name": "--force-po",
                    "content": "write PO file even if empty\n",
                    "long": "--force-po"
                },
                {
                    "name": "-i --indent",
                    "content": "write the .po file using indented style\n",
                    "flag": "-i",
                    "long": "--indent"
                },
                {
                    "name": "--no-location",
                    "content": "do not write '#: filename:line' lines\n",
                    "long": "--no-location"
                },
                {
                    "name": "-n --add-location",
                    "content": "generate '#: filename:line' lines (default)\n",
                    "flag": "-n",
                    "long": "--add-location"
                },
                {
                    "name": "--strict",
                    "content": "write out strict Uniforum conforming .po file\n",
                    "long": "--strict"
                },
                {
                    "name": "--properties-output",
                    "content": "write out a Java .properties file\n",
                    "long": "--properties-output"
                },
                {
                    "name": "--stringtable-output",
                    "content": "write out a NeXTstep/GNUstep .strings file\n",
                    "long": "--stringtable-output"
                },
                {
                    "name": "--itstool",
                    "content": "write out itstool comments\n",
                    "long": "--itstool"
                },
                {
                    "name": "-w --width",
                    "content": "set output page width\n",
                    "flag": "-w",
                    "long": "--width"
                },
                {
                    "name": "--no-wrap",
                    "content": "do not break long message lines, longer than the output page width, into several lines\n",
                    "long": "--no-wrap"
                },
                {
                    "name": "-s --sort-output",
                    "content": "generate sorted output\n",
                    "flag": "-s",
                    "long": "--sort-output"
                },
                {
                    "name": "-F --sort-by-file",
                    "content": "sort output by file location\n",
                    "flag": "-F",
                    "long": "--sort-by-file"
                },
                {
                    "name": "--omit-header",
                    "content": "don't write header with 'msgid \"\"' entry\n\n--copyright-holder=STRING\nset copyright holder in output\n",
                    "long": "--omit-header"
                },
                {
                    "name": "--foreign-user",
                    "content": "omit FSF copyright in output for foreign user\n\n--package-name=PACKAGE\nset package name in output\n\n--package-version=VERSION\nset package version in output\n\n--msgid-bugs-address=EMAIL@ADDRESS\nset report address for msgid bugs\n",
                    "long": "--foreign-user"
                },
                {
                    "name": "-m[STRING] --msgstr-prefix",
                    "content": "use STRING or \"\" as prefix for msgstr values\n",
                    "long": "--msgstr-prefix"
                },
                {
                    "name": "-M[STRING] --msgstr-suffix",
                    "content": "use STRING or \"\" as suffix for msgstr values\n",
                    "long": "--msgstr-suffix"
                },
                {
                    "name": "Informative output:",
                    "content": ""
                },
                {
                    "name": "-h --help",
                    "content": "display this help and exit\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-V --version",
                    "content": "output version information and exit\n",
                    "flag": "-V",
                    "long": "--version"
                },
                {
                    "name": "-v --verbose",
                    "content": "increase verbosity level\n",
                    "flag": "-v",
                    "long": "--verbose"
                }
            ]
        },
        "AUTHOR": {
            "content": "Written by Ulrich Drepper.\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "Report bugs in the bug tracker at <https://savannah.gnu.org/projects/gettext> or by email  to\n<bug-gettext@gnu.org>.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright  ©  1995-2020  Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or\nlater <https://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.  There is NO WARRANTY,  to\nthe extent permitted by law.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "The full documentation for xgettext is maintained as a Texinfo manual.  If the info and xget‐‐\ntext programs are properly installed at your site, the command\n\ninfo xgettext\n\nshould give you access to the complete manual.\n\n\n\nGNU gettext-tools 0.21                       March 2022                                  XGETTEXT(1)",
            "subsections": []
        }
    },
    "summary": "xgettext - extract gettext strings from source",
    "flags": [
        {
            "flag": "-f",
            "long": "--files-from",
            "arg": null,
            "description": "get list of input files from FILE"
        },
        {
            "flag": "-D",
            "long": "--directory",
            "arg": null,
            "description": "add DIRECTORY to list for input files search If input file is -, standard input is read."
        },
        {
            "flag": "-d",
            "long": "--default-domain",
            "arg": null,
            "description": "use NAME.po for output (instead of messages.po)"
        },
        {
            "flag": "-o",
            "long": "--output",
            "arg": null,
            "description": "write output to specified file"
        },
        {
            "flag": "-p",
            "long": "--output-dir",
            "arg": null,
            "description": "output files will be placed in directory DIR If output file is -, output is written to standard output."
        },
        {
            "flag": "-L",
            "long": "--language",
            "arg": null,
            "description": "recognise the specified language (C, C++, ObjectiveC, PO, Shell, Python, Lisp, Emac‐ sLisp, librep, Scheme, Smalltalk, Java, JavaProperties, C#, awk, YCP, Tcl, Perl, PHP, Ruby, GCC-source, NXStringTable, RST, RSJ, Glade, Lua, JavaScript, Vala, Desktop)"
        },
        {
            "flag": "-C",
            "long": "--c",
            "arg": null,
            "description": "shorthand for --language=C++ By default the language is guessed depending on the input file name extension."
        },
        {
            "flag": "-j",
            "long": "--join-existing",
            "arg": null,
            "description": "join messages with existing file"
        },
        {
            "flag": "-x",
            "long": "--exclude-file",
            "arg": null,
            "description": "entries from FILE.po are not extracted"
        },
        {
            "flag": "",
            "long": "--add-comments",
            "arg": null,
            "description": "place comment blocks starting with TAG and preceding keyword lines in output file"
        },
        {
            "flag": "-c",
            "long": "--add-comments",
            "arg": null,
            "description": "place all comment blocks preceding keyword lines in output file --check=NAME perform syntax check on messages (ellipsis-unicode, space-ellipsis, quote-unicode, bullet-unicode) --sentence-end=TYPE type describing the end of sentence (single-space, which is the default, or double-space)"
        },
        {
            "flag": "-a",
            "long": "--extract-all",
            "arg": null,
            "description": "extract all strings (only languages C, C++, ObjectiveC, Shell, Python, Lisp, Emac‐ sLisp, librep, Scheme, Java, C#, awk, Tcl, Perl, PHP, GCC-source, Glade, Lua, Java‐ Script, Vala)"
        },
        {
            "flag": "",
            "long": "--keyword",
            "arg": null,
            "description": "look for WORD as an additional keyword"
        },
        {
            "flag": "-k",
            "long": "--keyword",
            "arg": null,
            "description": "do not to use default keywords (only languages C, C++, ObjectiveC, Shell, Python, Lisp, EmacsLisp, librep, Scheme, Java, C#, awk, Tcl, Perl, PHP, GCC-source, Glade, Lua, JavaScript, Vala, Desktop) --flag=WORD:ARG:FLAG additional flag for strings inside the argument number ARG of keyword WORD (only languages C, C++, ObjectiveC, Shell, Python, Lisp, EmacsLisp, librep, Scheme, Java, C#, awk, YCP, Tcl, Perl, PHP, GCC-source, Lua, JavaScript, Vala)"
        },
        {
            "flag": "-T",
            "long": "--trigraphs",
            "arg": null,
            "description": "understand ANSI C trigraphs for input (only languages C, C++, ObjectiveC) --its=FILE apply ITS rules from FILE (only XML based languages) --qt recognize Qt format strings (only language C++) --kde recognize KDE 4 format strings (only language C++)"
        },
        {
            "flag": "",
            "long": "--boost",
            "arg": null,
            "description": "recognize Boost format strings (only language C++)"
        },
        {
            "flag": "",
            "long": "--debug",
            "arg": null,
            "description": "more detailed formatstring recognition result"
        },
        {
            "flag": "",
            "long": "--color",
            "arg": null,
            "description": "use colors and other text attributes always --color=WHEN use colors and other text attributes if WHEN. WHEN may be 'always', 'never', 'auto', or 'html'. --style=STYLEFILE specify CSS style rule file for --color"
        },
        {
            "flag": "-e",
            "long": "--no-escape",
            "arg": null,
            "description": "do not use C escapes in output (default)"
        },
        {
            "flag": "-E",
            "long": "--escape",
            "arg": null,
            "description": "use C escapes in output, no extended chars"
        },
        {
            "flag": "",
            "long": "--force-po",
            "arg": null,
            "description": "write PO file even if empty"
        },
        {
            "flag": "-i",
            "long": "--indent",
            "arg": null,
            "description": "write the .po file using indented style"
        },
        {
            "flag": "",
            "long": "--no-location",
            "arg": null,
            "description": "do not write '#: filename:line' lines"
        },
        {
            "flag": "-n",
            "long": "--add-location",
            "arg": null,
            "description": "generate '#: filename:line' lines (default)"
        },
        {
            "flag": "",
            "long": "--strict",
            "arg": null,
            "description": "write out strict Uniforum conforming .po file"
        },
        {
            "flag": "",
            "long": "--properties-output",
            "arg": null,
            "description": "write out a Java .properties file"
        },
        {
            "flag": "",
            "long": "--stringtable-output",
            "arg": null,
            "description": "write out a NeXTstep/GNUstep .strings file"
        },
        {
            "flag": "",
            "long": "--itstool",
            "arg": null,
            "description": "write out itstool comments"
        },
        {
            "flag": "-w",
            "long": "--width",
            "arg": null,
            "description": "set output page width"
        },
        {
            "flag": "",
            "long": "--no-wrap",
            "arg": null,
            "description": "do not break long message lines, longer than the output page width, into several lines"
        },
        {
            "flag": "-s",
            "long": "--sort-output",
            "arg": null,
            "description": "generate sorted output"
        },
        {
            "flag": "-F",
            "long": "--sort-by-file",
            "arg": null,
            "description": "sort output by file location"
        },
        {
            "flag": "",
            "long": "--omit-header",
            "arg": null,
            "description": "don't write header with 'msgid \"\"' entry --copyright-holder=STRING set copyright holder in output"
        },
        {
            "flag": "",
            "long": "--foreign-user",
            "arg": null,
            "description": "omit FSF copyright in output for foreign user --package-name=PACKAGE set package name in output --package-version=VERSION set package version in output --msgid-bugs-address=EMAIL@ADDRESS set report address for msgid bugs"
        },
        {
            "flag": "",
            "long": "--msgstr-prefix",
            "arg": null,
            "description": "use STRING or \"\" as prefix for msgstr values"
        },
        {
            "flag": "",
            "long": "--msgstr-suffix",
            "arg": null,
            "description": "use STRING or \"\" as suffix for msgstr values"
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "display this help and exit"
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "output version information and exit"
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "increase verbosity level"
        }
    ],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Extract gettext strings from code files.",
        "examples": [
            {
                "description": "Scan file and output strings to `messages.po`",
                "command": "xgettext {{path/to/input_file}}"
            },
            {
                "description": "Use a different output filename",
                "command": "xgettext {{-o|--output}} {{path/to/output_file}} {{path/to/input_file}}"
            },
            {
                "description": "Append new strings to an existing file",
                "command": "xgettext {{-j|--join-existing}} {{-o|--output}} {{path/to/output_file}} {{path/to/input_file}}"
            },
            {
                "description": "Don't add a header containing metadata to the output file",
                "command": "xgettext --omit-header {{path/to/input_file}}"
            },
            {
                "description": "Display help",
                "command": "xgettext {{-h|--help}}"
            }
        ]
    }
}