如何解决如何使用gettext?
我正在尝试了解如何使用 gettext。以下工作流程无法正确检索法语文本。有人能告诉我如何让它工作吗?
$ cat po/fr/hello.po
msgid "Hello World\n"
msgstr "Bonjour le monde\n"
$ msgfmt -o po/fr/hello.mo po/fr/hello.po
$ cp po/fr/hello.mo fr/LC_MESSAGES/hello.mo
$ cat hello.c
#include <stdio.h>
#include <stdlib.h>
#include <libintl.h>
#include <locale.h>
#define _(STRING) gettext(STRING)
int main() {
/* Setting the i18n environment */
setlocale (LC_ALL,"");
bindtextdomain ("hello","/usr/share/locale/");
textdomain ("hello");
/* Example of i18n usage */
printf(_("Hello World\n"));
return EXIT_SUCCESS;
}
$ gcc -o hello.exe hello.c
$ LANG=fr_FR ./hello.exe
Hello World
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。