Let’s define this problem by an example. This is the kind of text I want to modify.
# include <stdio.h>
void main(int argc, char ** argv) {
printf("Hello world!\n");
printf("Version 2.0\n\
You can use this program as you want.\n");
return 0;
}
This is a C program but I want to use gettext to provide translated version of
this program easily. Usually, the solution is to replace each string by a call
to a function (the string being the key). I will not enter in details of
gettext here but to resume, we want something like this as the result.
# include <stdio.h>
void main(int argc, char ** argv) {
printf(_("Hello world!\n"));
printf(_("Version 2.0\n\
You can use this program as you want.\n"));
return 0;
}
Note that each string has been nested into the function _()
wich is the usual
convention for gettext. If you want the quick solution, go directly to the
end of this article.