XGETTEXT(1) User Commands XGETTEXT(1)

# [NAME](#NAME)

xgettext - extract gettext strings from source

# [SYNOPSIS](#SYNOPSIS)

**xgettext** \[*OPTION*] \[*INPUTFILE*]...

# [DESCRIPTION](#DESCRIPTION)

Extract translatable strings from given input files.

Mandatory arguments to long options are mandatory for short options too. Similarly for optional arguments.

## [Input file location:](#Input_file_location:)

[INPUTFILE ...](#INPUTFILE)

input files

[**-f**, **--files-from**=*FILE*](#f)

get list of input files from FILE

[**-D**, **--directory**=*DIRECTORY*](#D)

add DIRECTORY to list for input files search

If input file is -, standard input is read.

## [Output file location:](#Output_file_location:)

[**-d**, **--default-domain**=*NAME*](#d)

use NAME.po for output (instead of messages.po)

[**-o**, **--output**=*FILE*](#o)

write output to specified file

[**-p**, **--output-dir**=*DIR*](#p)

output files will be placed in directory DIR

If output file is -, output is written to standard output.

## [Choice of input file language:](#Choice_of_input_file_language:)

[**-L**, **--language**=*NAME*](#L)

recognise the specified language (C, C++, ObjectiveC, PO, Python, Java, JavaProperties, C#, JavaScript, TypeScript, TSX, Scheme, Guile, Lisp, EmacsLisp, librep, Rust, Go, Ruby, Shell, awk, Lua, Modula-2, D, OCaml, Smalltalk, Vala, Tcl, Perl, PHP, GCC-source, YCP, NXStringTable, RST, RSJ, Glade, GSettings, Desktop)

[**-C**, **--c**++](#C)

shorthand for **--language**=*C*++

By default the language is guessed depending on the input file name extension.

## [Input file interpretation:](#Input_file_interpretation:)

[**--from-code**=*NAME*](#from)

encoding of input files (except for Python, Tcl, Glade)

By default the input files are assumed to be in ASCII.

## [Operation mode:](#Operation_mode:)

[**-j**, **--join-existing**](#j)

join messages with existing file

[**-x**, **--exclude-file**=*FILE*.po](#x)

entries from FILE.po are not extracted

[**-cTAG**, **--add-comments**=*TAG*](#cTAG)

place comment blocks starting with TAG and preceding keyword lines in output file

[**-c**, **--add-comments**](#c)

place all comment blocks preceding keyword lines in output file

[**--check**=*NAME*](#check)

perform syntax check on messages (ellipsis-unicode, space-ellipsis,

quote-unicode, bullet-unicode)

[**--no-check**=*NAME*](#no)

don't perform syntax check on messages (url, email)

[**--sentence-end**=*TYPE*](#sentence)

type describing the end of sentence (single-space, which is the default,

or double-space)

## [Language specific options:](#Language_specific_options:)

[**-a**, **--extract-all**](#a)

extract all strings (only languages C, C++, ObjectiveC, Python, Java, C#, JavaScript, TypeScript, TSX, Scheme, Guile, Lisp, EmacsLisp, librep, Rust, Go, Shell, awk, Lua, Modula-2, D, OCaml, Vala, Tcl, Perl, PHP, GCC-source, Glade, GSettings)

[**-kWORD**, **--keyword**=*WORD*](#kWORD)

look for WORD as an additional keyword

[**-k**, **--keyword**](#k)

do not to use default keywords (only languages C, C++, ObjectiveC, Python, Java, C#, JavaScript, TypeScript, TSX, Scheme, Guile, Lisp, EmacsLisp, librep, Rust, Go, Shell, awk, Lua, Modula-2, D, OCaml, Vala, Tcl, Perl, PHP, GCC-source, Glade, GSettings, Desktop)

[**--flag**=*WORD*:ARG:FLAG](#flag)

additional flag for strings inside the argument number ARG of keyword WORD

(only languages C, C++, ObjectiveC, Python,

Java, C#, JavaScript, TypeScript, TSX, Scheme, Guile, Lisp, EmacsLisp, librep, Rust, Go, Shell, awk, Lua, Modula-2, D, OCaml, Vala, Tcl, Perl, PHP, GCC-source, YCP)

[**--tag**=*WORD*:FORMAT](#tag)

defines the behaviour of tagged template literals with tag WORD

(only language JavaScript)

[**-T**, **--trigraphs**](#T)

understand ANSI C trigraphs for input (deprecated; only languages C, C++, ObjectiveC)

[**--its**=*FILE*](#its)

apply ITS rules from FILE (only XML based languages)

[**--qt**](#qt)

recognize Qt format strings (only language C++)

[**--kde**](#kde)

recognize KDE 4 format strings (only language C++)

[**--boost**](#boost)

recognize Boost format strings (only language C++)

[**--debug**](#debug)

more detailed formatstring recognition result

## [Output details:](#Output_details:)

[**--color**](#color)

use colors and other text attributes always

[**--color**=*WHEN*](#color~2)

use colors and other text attributes if WHEN. WHEN may be 'always', 'never', 'auto', or 'html'.

[**--style**=*STYLEFILE*](#style)

specify CSS style rule file for **--color**

[**-e**, **--no-escape**](#e)

do not use C escapes in output (default)

[**-E**, **--escape**](#E)

use C escapes in output, no extended chars

[**--force-po**](#force)

write PO file even if empty

[**-i**, **--indent**](#i)

write the .po file using indented style

[**--no-location**](#no~2)

do not write '#: filename:line' lines

[**-n**, **--add-location**](#n)

generate '#: filename:line' lines (default)

[**--strict**](#strict)

write out strict Uniforum conforming .po file

[**--properties-output**](#properties)

write out a Java .properties file

[**--stringtable-output**](#stringtable)

write out a NeXTstep/GNUstep .strings file

[**--itstool**](#itstool)

write out itstool comments

[**-w**, **--width**=*NUMBER*](#w)

set output page width

[**--no-wrap**](#no~3)

do not break long message lines, longer than the output page width, into several lines

[**-s**, **--sort-output**](#s)

generate sorted output (deprecated)

[**-F**, **--sort-by-file**](#F)

sort output by file location

[**--omit-header**](#omit)

don't write header with 'msgid ""' entry

[**--no-git**](#no~4)

don't use the git program to produce a reproducible 'POT-Creation-Date' field in the output.

[**--copyright-holder**=*STRING*](#copyright)

set copyright holder in output

[**--foreign-user**](#foreign)

omit FSF copyright in output for foreign user

[**--package-name**=*PACKAGE*](#package)

set package name in output

[**--package-version**=*VERSION*](#package~2)

set package version in output

[**--msgid-bugs-address**=*EMAIL*@ADDRESS](#msgid)

set report address for msgid bugs

[**--generated**=*FILE*](#generated)

Declares that the given FILE is generated and therefore should not have an influence on the 'POT-Creation-Date' field in the output.

[**--reference**=*FILE*](#reference)

Declares that the output depends on the contents of the given FILE. This has an influence on the 'POT-Creation-Date' field in the output.

[**-m\[STRING\]**, **--msgstr-prefix**\[=*STRING*\]](#m_STRING_)

use STRING or "" as prefix for msgstr values

[**-M\[STRING\]**, **--msgstr-suffix**\[=*STRING*\]](#M_STRING_)

use STRING or "" as suffix for msgstr values

## [Informative output:](#Informative_output:)

[**-h**, **--help**](#h)

display this help and exit

[**-V**, **--version**](#V)

output version information and exit

[**-v**, **--verbose**](#v)

increase verbosity level

# [AUTHOR](#AUTHOR)

Written by Ulrich Drepper and Bruno Haible.

# [REPORTING BUGS](#REPORTING_BUGS)

Report bugs in the bug tracker at &lt;https://savannah.gnu.org/projects/gettext&gt; or by email to &lt;bug-gettext@gnu.org&gt;.

# [COPYRIGHT](#COPYRIGHT)

Copyright © 1995-2026 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later &lt;https://gnu.org/licenses/gpl.html&gt;  
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

# [SEE ALSO](#SEE_ALSO)

The full documentation for **xgettext** is maintained as a Texinfo manual. If the **info** and **xgettext** programs are properly installed at your site, the command

**info xgettext**

should give you access to the complete manual.

August 2026 GNU gettext-tools 1.0

---

Document: xgettext(1) from gettext 1.0-r7 (Chainguard OS)
Source: https://git.savannah.gnu.org/git/gettext.git
