- 論壇徽章:
- 0
|
用glade+anjuta開發(fā),glade畫界面,anjuta就會自動生成main.c。悖幔欤欤猓幔悖耄恪nterface.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目錄),然后運(yùn)行configure,make,make。椋睿螅簦幔欤彀惭b我的程序,然后我再建立/usr/local/language/share/local/en/LC_MESSAGES文件夾,其中l(wèi)ocal/en/LC_MESSAGES這部分是原來沒有的,然后把四個c文件cp到/usr/local/language/share/local/en/LC_MESSAGES,執(zhí)行xgettext -n *.c這時候生成了messages.po文件,po文件內(nèi)容如下:
[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"
然后我再運(yùn)行msgfmt。恚澹螅螅幔纾澹螅穑锞统霈F(xiàn)了一個提示信息:
[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.
此時我運(yùn)行我安裝后的程序,界面上就有一個button,正常運(yùn)行后就應(yīng)該彈出一個message,顯示ddddd,然后單擊那個button顯示bbb,但是現(xiàn)在是運(yùn)行后沒有顯示ddddd,點擊button時候只是彈出了aaa,而不是我要翻譯后的bbb
請各位幫忙,小艾謝謝大家 |
|