How can I use gettext in vala?
Asked Answered
E

3

5

When I try to use gettext in vala I get not errors or warnings from vala but I get the following error from the 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?

Evita answered 28/8, 2011 at 15:8 Comment(0)
E
5

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

If I don't add that to the top of my source file, I get lots of undeclared (first use in this function) errors from the C compiler for some reason.

I do, however, get a warning from the C compiler for redefining GETTEXT_PACKAGE.

Evita answered 28/8, 2011 at 18:53 Comment(2)
To avoid the dupplicate GETTEXT_PACKAGE values, you may use [CCode(cname="GETTEXT_PACKAGE")] extern const string GETTEXT_PACKAGE; instead of const string GETTEXT_PACKAGE = "...";.Gert
Or just: extern const string GETTEXT_PACKAGE; I believe it's sufficient.Truck
V
3

I think the most common solution is to just pass -DGETTEXT_PACKAGE="..." to the C compiler (if you're just relying on valac to invoke it, pass -X -DGETTEXT_PACKAGE="..." to valac).

Veliavelick answered 28/8, 2011 at 18:17 Comment(0)
C
2

This can help: https://bugzilla.gnome.org/show_bug.cgi?id=618931

Clinometer answered 28/8, 2011 at 15:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.