如何在vala中使用gettext? [英] How can I use gettext in vala?
问题描述
当我尝试在vala中使用gettext时,我没有从vala中收到错误或警告,但从c编译器中收到了以下错误:
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?
我该如何解决?
推荐答案
要解决此问题,我必须将-X -DGETTEXT_PACKAGE="..."
添加到valac命令中,并将const string GETTEXT_PACKAGE = "...";
添加到源文件的顶部.
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.
如果不将其添加到源文件的顶部,由于某种原因,我会从C编译器中收到许多undeclared (first use in this function)
错误.
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.
但是,我确实从C编译器收到警告,要求重新定义GETTEXT_PACKAGE.
I do, however, get a warning from the C compiler for redefining GETTEXT_PACKAGE.
这篇关于如何在vala中使用gettext?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!