How to use gettext in vala?

When I try to use gettext in vala, I get no errors or warnings from vala, but I get the following error from c compiler:

/usr/include/glib-2.0/glib/gi18n-lib.h:29:2: error: #error You must define GETTEXT_PACKAGE before including gi18n-lib.h. Did you forget to include config.h? 

How can i fix this?

+4
source share
3 answers

To solve this problem I had to add the command -X -DGETTEXT_PACKAGE="..." to the valac command and add const string GETTEXT_PACKAGE = "..."; to the beginning of my source file.

If I do not add this to the beginning of my source file, for some reason I get many undeclared (first use in this function) errors undeclared (first use in this function) from the C compiler.

However, I get a warning from the C compiler to override GETTEXT_PACKAGE.

+4
source

I think the most common solution is to simply pass -DGETTEXT_PACKAGE = "..." to the C compiler (if you just rely on valac to call it, pass -X -DGETTEXT_PACKAGE = "..." to valac).

+2
source

Source: https://habr.com/ru/post/1369380/


All Articles