利用gettext工具翻译项目documentor
主文件加
Documentor.ec
Code: Select all
#include <locale.h>
#include <libintl.h>
#include <stdlib.h>
#define PACKAGE "documentor"
#define LOCALEDIR "locale"
#define _(STRING) gettext(STRING)
Code: Select all
class Ecgettext
{
Ecgettext()
{
char * lang = "cn"; //change language
putenv("LANG=zh_CN");
setlocale(LC_ALL, "zh_CN");
/*
if ("cn" == lang) {
putenv("LANG=zh_CN");
setlocale(LC_ALL, "zh_CN");
} else if ("en" == lang) {
putenv("LANG=en_US");
setlocale(LC_ALL, "en_US");
}
*/
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
bind_textdomain_codeset (PACKAGE, "utf-8"); ///newlines
}
}
Ecgettext eclanguage { };
SettingsDialog.ec
Code: Select all
#include <locale.h>
#include <libintl.h>
#define _(STRING) gettext(STRING)
然后利用poedit翻译生成po和mo文件,放到指定位置