当前位置: 技术问答>linux和unix
gtk多国化问题
来源: 互联网 发布时间:2016-12-10
本文导语: 用的红帽6,按照http://hi.baidu.com/ofchaos/blog/item/d4fcf3f85d26f505d8f9fd49.html来到,但怎么搞都是现实的英文,请大家帮忙看看哪里有问题 locale看是zh_CN.utf8 #include #include #include #define PACKAGE "window" #define LOCALEDIR "./locale...
用的红帽6,按照http://hi.baidu.com/ofchaos/blog/item/d4fcf3f85d26f505d8f9fd49.html来到,但怎么搞都是现实的英文,请大家帮忙看看哪里有问题
locale看是zh_CN.utf8
locale看是zh_CN.utf8
#include
#include
#include
#define PACKAGE "window"
#define LOCALEDIR "./locale"
#define _(string) gettext(string)
#define N_(string) string
int main(int argc, char *argv[])
{
GtkWidget *window;
bindtextdomain(PACKAGE,LOCALEDIR);
bind_textdomain_codeset(PACKAGE, "UTF-8");
textdomain(PACKAGE);
gtk_init(&argc,&argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
// window = gtk_window_new(GTK_WINDOW_POPUP);
g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(gtk_main_quit),NULL);
gtk_window_set_title(GTK_WINDOW(window),N_("hello"));
g_print("%sn",_("hello"));
gtk_window_set_default_size(GTK_WINDOW(window),500,100);
gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
gtk_widget_show(window);
gtk_main();
return FALSE;
}
# 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 , YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSIONn"
"Report-Msgid-Bugs-To: n"
"POT-Creation-Date: 2011-05-05 20:02+0800n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONEn"
"Last-Translator: FULL NAME n"
"Language-Team: LANGUAGE n"
"MIME-Version: 1.0n"
"Content-Type: text/plain; charset=CHARSETn"
"Content-Transfer-Encoding: 8bitn"
#: window.c:19 window.c:20
msgid "hello"
msgstr ""
|
(1)你第2段代码应该是po文件,但好像不是你这个写法,给个例子你:
其它罗里八嗦的都不要,文件名要存为zh_CN.po
(2)po文件要编译成mo
命令是:msgfmt zh_CN.po
"Content-Type: text/plain; charset=utf-8n"
"Content-Transfer-Encoding: 8bitn"
#: ../ui.glade.h:1
msgid "Age"
msgstr "年龄"
其它罗里八嗦的都不要,文件名要存为zh_CN.po
(2)po文件要编译成mo
命令是:msgfmt zh_CN.po