【问题标题】:getting localised string获取本地化字符串
【发布时间】:2010-12-27 11:44:17
【问题描述】:

我从 fr_FR.po 创建了一个本地化的 fr_FR_Locale.mo 文件。

我已经从终端使用了 sgettextmsginitmsgfmt 命令。

我已将本地更改为 french(fr_FR.utf8)

但是当我执行我的代码时,我没有得到我所期望的。这是我的电话:

setlocale(LC_ALL,"");
bindtextdomain("locale",LC_INTL);
bind_textdomain_codeset("locale", "UTF-8");
textdomain("locale");
printf(gettext("Hello world!"));   

这里的输出应该是一些东西非英语, 但我得到相同的英文单词

【问题讨论】:

  • 我们可以看看你的gettext()函数吗?
  • @marcog:我正在使用以下标头:#include #include
  • 这与在语言环境名称字符串中使用错误形式的编码名称(utf8 而不是UTF-8)有关吗?
  • 不,它没有做任何改变......

标签: c localization gnome


【解决方案1】:

可能找不到您的 mo 文件。我不知道 LC_INTL 是什么意思,也不知道你安装 mo 文件的位置。但是假设您将其安装为/usr/local/share/locale/fr/LC_MESSAGES/MyApp.mo,代码应如下所示:

setlocale(LC_ALL,"");
bindtextdomain("MyApp","/usr/local/share/locale");
bind_textdomain_codeset("MyApp","UTF-8");
textdomain("MyApp");

【讨论】:

    猜你喜欢
    • 2012-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多