dcngettext - Linux


dcngettext is a command-line tool used to extract gettext strings from D applications (D source code compiled into C). It allows you to internationalize your D applications by providing localized translations for your interface.


dcngettext [options] <source files>


  • -o : Specify an output file for the extracted gettext strings. Defaults to messages.pot.
  • -l : Specify a specific locale to extract strings for. Defaults to the system’s default locale.
  • –recurse: Recursively search for source files in subdirectories.
  • -h, –help: Display help information.
  • -v, –version: Display version information.


Simple Extraction:

Extract gettext strings from a single D source file:

dcngettext myfile.d

Output to Specific File:

Extract strings and save them in a custom output file:

dcngettext -o my_translations.pot myfile.d

Specify Locale:

Extract strings for a specific locale (e.g., French):

dcngettext -l fr myfile.d

Recursive Search:

Recursively search for D source files in the current directory and subdirectories:

dcngettext --recurse

Common Issues

  • Missing Gettext Calls: Ensure that all translatable strings are wrapped in gettext() calls.
  • Locale Not Found: If a specified locale is not installed on your system, dcngettext will fail. Install the required locale package.
  • Syntax Errors: Check the D source files for any syntax errors that may interfere with dcngettext’s extraction.


Combine dcngettext with other tools for advanced localization tasks:

  • msgfmt: Convert extracted .po files to binary .mo files.
  • msginit: Create an initial .po file template.
  • xgettext: Extract gettext strings from various source formats.

Related Commands

  • dmd: D compiler
  • gettextize: Prepare a source directory for translation
  • msgmerge: Merge translated messages with existing message catalogs