gettext - 如何使用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
解决方案
推荐阅读
- java - 如何真正从系统类中清除属性?
- vba - 使用 VBA 通过 gmail 发送电子邮件的 CDO.message 的任何替代方案
- reactjs - ChartJS - 定位和查看水平条的各种组件的问题
- c++ - 在c ++中那个闰年程序中的指令编码是否明智?
- javascript - 动画导航与另一个导航一起移动
- linux - 使用 ls 时权限被拒绝
- html - 有延迟的动画
- python - 如何在计算曲线拟合时将数据框系列或数组传递给指数函数
- python - 烧瓶后台线程 - 503 错误
- reactjs - 为什么 justify-content-center 不能在反应中工作?