- 论坛徽章:
- 0
|
用glade+anjuta开发,glade画界面,anjuta就会自动生成main.c callback.c interface.c 和support.c四个c文件,还有其他
我把我的这两个main。c,callback.c文件贴出来
callback.c
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gnome.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
void
on_button1_clicked (GtkButton *button,
gpointer user_data)
{
char *contp;
contp = gettext("aaa");
GtkWidget *msgbox = gnome_app_new("Hello World", "Hello World");
gnome_app_message (GNOME_APP(msgbox), contp);
}
main.c
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gnome.h>
#include "interface.h"
#include "support.h"
//#define _(String) gettext(String)
//#define N_(String) gettext(String)
//#define _ _(String) (String)
int
main (int argc, char *argv[])
{
GtkWidget *window1;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
argc, argv,
GNOME_PARAM_APP_DATADIR, PACKAGE_DATA_DIR,
NULL);
/*
* The following code was added by Glade to create one of each component
* (except popup menus), just so that you see something after building
* the project. Delete any components that you don't want shown initially.
*/
window1 = create_window1 ();
gtk_widget_show (window1);
gtk_main ();
setlocale(LC_ALL, "en");
bindtextdomain("language", "/usr/local/language/share/local/");
//textdomain("language");
GtkWidget *msgbox = gnome_app_new("Hello World", "Hello World");
gnome_app_message (GNOME_APP(msgbox),gettext("Some String"));
gnome_app_message (GNOME_APP(msgbox),GETTEXT_PACKAGE);
// printf(gettext("Some String"));
return 0;
}
弄好c文件,然后我配置configure安装在/usr/local/language/(因为我的项目名称叫做language,所以我在/usr/local/下建立了一个language目录),然后运行configure,make,make install安装我的程序,然后我再建立/usr/local/language/share/local/en/LC_MESSAGES文件夹,其中local/en/LC_MESSAGES这部分是原来没有的,然后把四个c文件cp到/usr/local/language/share/local/en/LC_MESSAGES,执行xgettext -n *.c这时候生成了messages.po文件,po文件内容如下:
[root@FC5TEST LC_MESSAGES]# cat messages.po
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-08-09 11:07+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: callbacks.c:17
msgid "aaa"
msgstr "bbb"
#: main.c:48
msgid "Some String"
msgstr "ddddd"
然后我再运行msgfmt messages.po就出现了一个提示信息:
[root@FC5TEST LC_MESSAGES]# msgfmt messages.po
msgfmt: messages.po: warning: Charset "CHARSET" is not a portable encoding name.
Message conversion to user's charset might not work.
此时我运行我安装后的程序,界面上就有一个button,正常运行后就应该弹出一个message,显示ddddd,然后单击那个button显示bbb,但是现在是运行后没有显示ddddd,点击button时候只是弹出了aaa,而不是我要翻译后的bbb
请各位帮忙,小艾谢谢大家 |
|