How can I use gettext in vala?

ⅰ亾dé卋堺 提交于 2019-12-10 16:47:30

问题


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?


回答1:


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.




回答2:


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).




回答3:


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



来源:https://stackoverflow.com/questions/7221754/how-can-i-use-gettext-in-vala

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!