在格式字符串前加下划线_ [英] Underscore `_` before the format string

查看:98
本文介绍了在格式字符串前加下划线_的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里查看一些C源代码,发现了这一点:

I'm here looking at some C source code and I've found this:

fprintf(stderr, _("Try `%s --help' for more information.\n"), 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆