Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does _("text"), i.e. underscore bracket char, do? [duplicate]

Tags:

c

In C code I came across this bit

_("test")

What does it do? (I tried to look it up myself, but as you can imagine, search engines do not support searching for that...)

like image 699
navige Avatar asked Mar 06 '13 10:03

navige


1 Answers

It is calling the function called _. For instance:

#include <stdio.h>

void _(int a) {
    printf("%d",a);
}
int main(void) {
         _(3);
        return 0;
}

_ is an existing function in gettext library and is used for internationalization. As said in this answer:

This function basically replaces the given string on runtime with a translation in the system's language, if available (i.e. if they shipped a .mo file for this language with the program).

like image 109
Ivaylo Strandjev Avatar answered Nov 18 '22 04:11

Ivaylo Strandjev