0

I have an C application that makes use of ansi color codes which are defined like this:

#define RED   "\x1b[31;01m"
#define RESET "\x1b[0m"

These defines are used in prints to color the output:

/* Actual example: */
log_error(_(RED"FATAL: "RESET"Aborting due to a fatal error."))

So, here's the actual problem: How to make xgettext play nicely with those color escapes? Currently running xgettext on this kind of source produces a .pot entry like this:

#: src/main.c:89
msgid "FATAL: "
msgstr ""

As you see, not the full string is recognized. Any ideas on how to change this? I was unable to find an answer in man xgettext.

Edit: I assume the solution is "use %s for the color escapes", but I'd like to prevent that.

Sahib
  • 223
  • 1
  • 10
  • can you create a `log_error` function with multiple parameters? for example `log_error(int severity, string message);` and determine inside the function which text and color to use, and join all strings. – wimh Nov 01 '14 at 23:33
  • @Wimmel: Sadly, the severity is not always connected to the color being used. – Sahib Nov 01 '14 at 23:41

0 Answers0