格式字符串前的下划线`_` [英] Underscore `_` before the format string
问题描述
我在这里查看一些 C 源代码,我发现了这个:
I'm here looking at some C source code and I've found this:
fprintf(stderr, _("Try `%s --help' for more information.
"), command);
我在查看 wxWidget 时已经看到了下划线,我读到它是用于国际化的.我发现它真的很可怕(有史以来最不直观的名字),但我认为这只是另一个奇怪的 wxWidget 约定.
I already saw the underscore when I had a look at wxWidget, and I read it's used for internationalization. I found it really horrible (the least intutive name ever), but I tought it's just another weird wxWidget convention.
现在我在一些 Alsa 资源中再次找到它.有谁知道它来自哪里?
Now I find it again in some Alsa source. Does anyone know where it comes from?
推荐答案
它来自 GNU gettext
,一个旨在简化国际化过程的包._()
函数只是一个字符串包装器.这个函数基本上在运行时用系统语言的翻译替换给定的字符串,如果可用的话(即,如果他们为程序提供了该语言的 .mo
文件).
It comes from GNU gettext
, a package designed to ease the internationalization process. The _()
function is simply a string wrapper. This function basically replaces the given string on runtime with a translation in the system's language, if available (i.e. if they shipped a .mo
file for this language with the program).
这篇关于格式字符串前的下划线`_`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!