Ecere SDK/eC Forums • View topic - 在windows下测试gettext没成功




Ecere SDK/eC Forums

Ecere Developers Community

在windows下测试gettext没成功

来自中国的朋友,欢迎您在本版面使用中文讨论问题。请注意,如果您想得到不懂中文的人的帮助,请同时提供英文译文。
Help and discussions in Chinese.

在windows下测试gettext没成功

Postby liqi98136 » Thu Aug 18, 2011 5:26 am

在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
liqi98136
 
Posts: 53
Joined: Sun Jan 17, 2010 11:37 pm

Re: 在windows下测试gettext没成功

Postby liqi98136 » Thu Aug 18, 2011 5:29 am

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

失败 :(
liqi98136
 
Posts: 53
Joined: Sun Jan 17, 2010 11:37 pm

Re: 在windows下测试gettext没成功

Postby liqi98136 » Thu Aug 18, 2011 5:33 am

不使用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!


:( 失败
liqi98136
 
Posts: 53
Joined: Sun Jan 17, 2010 11:37 pm

Re: 在windows下测试gettext没成功

Postby liqi98136 » Thu Aug 18, 2011 5:38 am

收获 :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中编辑
(82 KiB) Downloaded 13915 times
liqi98136
 
Posts: 53
Joined: Sun Jan 17, 2010 11:37 pm


Return to 欢迎使用中文讨论

Who is online

Users browsing this forum: No registered users and 5 guests

cron