Ecere SDK/eC Forums
http://ec-lang.org/community/
Print view

在windows下测试gettext没成功
http://ec-lang.org/community/viewtopic.php?f=30&t=149
Page 1 of 1
Author:  liqi98136 [ Thu Aug 18, 2011 5:26 am ]
Post subject:  在windows下测试gettext没成功

在windows下测试gettext没成功,我把过程写下来,看看问题出哪了.
下载安装包
install package download
poedit
7z921.exe
mingw tools
libiconv-1.13.1-1-mingw32-dev.tar.lzma
gettext-0.17-1-mingw32-dev.tar.lzma
解压到wingw

写程序

Code: Select all

/*****hello.ec******/
#include <locale.h>
#include <libintl.h>
#include <gettext.h>


#define PACKAGE "hello"
#define LOCALEDIR "languages"
#define N_(msgid) gettext(msgid)
#define __printf__ printf

import "ecere"

class helloApp : Application
{
void Main()
{
   setlocale(LC_CTYPE, "");
   setlocale(LC_MESSAGES, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
   printf(N_("this is a string\n"));
   system("pause");
}
}
打开poedit
new
tab1
//////////
ecere0.44
tm
tm@ecere.com
Chinese
UTF-8
utf-8
nplurals=2; plural=(n!=1);
////////////
tab2
/////////
F:\work\temp
.
//////////
tab3
/////////
N_
/////////

save and open hello.po
修改
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Type: text/plain; charset=UTF-8\n"

msgsid "this is a string\n"
msgstr "这是一个字符串\n"

关闭poedit
将hello.mo放到程序目录下 languages/zh_CN/LC_MESSAGES/hello.mo
Author:  liqi98136 [ Thu Aug 18, 2011 5:29 am ]
Post subject:  Re: 在windows下测试gettext没成功

Poedit\bin\xgettext --keyword=N_ -o hello.po hello.ec
修改
"Content-Type: text/plain; charset=CHARSET\n"

"Content-Type: text/plain; charset=UTF-8\n"


msgsid "this is a string\n"
增加
msgstr "这是一个字符串\n"

Poedit\bin\msgfmt -o languages/zh_CN/LC_MESSAGES/hello.mo hello.po

失败 :(
Author:  liqi98136 [ Thu Aug 18, 2011 5:33 am ]
Post subject:  Re: 在windows下测试gettext没成功

不使用EcIDE

Code: Select all

#include <stdio.h> 
#include <locale.h> 
#include <libintl.h> 
#include <gettext.h>
#define _(S) gettext(S) 
#define __printf__ printf
#define PACKAGE "jian_gettext" 
int main(int argc, char **argv) 
{ 
	setlocale(LC_ALL,"");
	bindtextdomain(PACKAGE, "locale"); 
	textdomain(PACKAGE); 
	printf(_("Hello,GetText!\n")); 
	
	return 0; 
}
F:\Poedit\bin\xgettext -a jian_gettext.c -o jian_gettext.po --from-code=utf-8
修改jian_gettext.po文符集改为UFT-8
翻译
msgstr "你好,GetText!\n"

mkdir languages\zh_CN\LC_MESSAGES\
copy jian_gettext.mo languages\zh_CN\LC_MESSAGES\
gcc -Wall -o jian_gettext jian_gettext.c
jian_gettext
Hello,GetText!


:( 失败
Author:  liqi98136 [ Thu Aug 18, 2011 5:38 am ]
Post subject:  Re: 在windows下测试gettext没成功

收获 :P
解压ecere_sdk
进入运行
dir *.ec /s /b >filelist.txt
f:\poedit\bin\xgettext -a -f filelist.txt -o ecere.po -from-code=utf-8

将列表中Menu.ec去除,要不会出错
得到字符串列表
MYecere.po.7z
MYecere.po.7z
ecere字符串列表可在poedit中编辑
(81.67 KiB) Downloaded 7840 times
All times are UTC-05:00 Page 1 of 1