c - dcgettext 的目的是什么?

标签 c linux internationalization gettext

GNU gettext 手册对dcgettext 函数的描述如下:

Both take an additional argument at the first place, which corresponds to the argument of textdomain. The third argument of dcgettext allows to use another locale category but LC_MESSAGES. But I really don’t know where this can be useful. If the domain_name is NULL or category has an value beside the known ones, the result is undefined. It should also be noted that this function is not part of the second known implementation of this function family, the one found in Solaris.

来源:https://www.gnu.org/software/gettext/manual/html_node/Ambiguities.html

是否有任何用于提供不同于默认LC_MESSAGES 的消息翻译类别?它甚至会做什么? (它是否使用该不同类别的语言环境设置而不是 LC_MESSAGES 的语言环境设置?如果设置了 LANGUAGE 会发生什么 - 无论如何它不会覆盖该类别,或者它只覆盖 LC_MESSAGES 吗?)因为即使是文档编写者也在努力寻找此功能的用途,我真的很怀疑它是否有任何用途。尝试

ls /usr/share/locale/*/LC_[^M]*

没有找到任何文件,所以似乎没有人在使用它。但是任何人都可以提供有关此功能的用途/用途以及它是否有用的见解吗?

最佳答案

显然 dcgettext 是“为了兼容性”而提供的。

引用 GNU C 库的 Translation with gettext部分,倒数第三段:

The dcgettext function is only implemented for compatibility with other systems which have gettext functions. There is not really any situation where it is necessary (or useful) to use a different value but LC_MESSAGES in for the category parameter. We are dealing with messages here and any other choice can only be irritating.

(就我个人而言,我并不认为这是一个特别令人满意的答案,因为它没有给出有关哪些他们正在寻求与兼容的“其他系统”的提示——但是这是迄今为止我找到的唯一权威解释。)

关于c - dcgettext 的目的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24977489/

相关文章:

Qt linguist lupdate 忽略 qml 文件

file - SilverStripe 文件标题翻译

c - 为什么 GCC 会将字复制到返回寄存器而不是字节?

linux - 在 openSUSE 上启动时运行脚本

c++ - 错误 : cannot call constructor

linux - 通过 ELB 和 Linux 将 Amazon 上的 https 流量重定向到 S3 上的静态站点

html - 标签文件上传按钮

c - C 程序 malloc 赋值返回 NULL 的可能原因?

c - 使用 gcc 优化 -mavx 失败?

c - 冒泡排序选项。需要添加一个打印气泡位移的(print_bubble)程序