gettext library : i18n for c
So in another code reading note I looked into some “standard” initialzation routines of a typical GNU (coreutils) program. And a good chunk of the initialzation is regarding localization (i18n). Here are more notes on this topic.
Well I saw something like this
_("text")
and was like … is there a C syntax rule I don’t know?
Then realized it’s a fucking function called _()
.. e.g.
#define _(Text) gettext (Text)
man 3 gettext
NAME
gettext, dgettext, dcgettext - translate message
SYNOPSIS
#include <libintl.h>
char * gettext (const char * msgid);
char * dgettext (const char * domainname, const char * msgid);
char * dcgettext (const char * domainname, const char * msgid,
int category);
DESCRIPTION
The gettext, dgettext and dcgettext functions attempt to translate a text string into the user's native lan‐
guage, by looking up the translation in a message catalog.