免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2391 | 回复: 8
打印 上一主题 下一主题

问个土问题,Return _("XXX");的下划线做何用途 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-05-11 14:55 |只看该作者 |倒序浏览
return _("it is based on your username";

这里的下划线是做什么用的呢?

谢谢.

论坛徽章:
3
金牛座
日期:2014-06-14 22:04:062015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:49:45
2 [报告]
发表于 2009-05-11 15:02 |只看该作者

回复 #1 MaxWu 的帖子

这个是win下面的吧

论坛徽章:
0
3 [报告]
发表于 2009-05-11 15:13 |只看该作者
是不是表示宽字符。。。忘了

论坛徽章:
95
程序设计版块每日发帖之星
日期:2015-09-05 06:20:00程序设计版块每日发帖之星
日期:2015-09-17 06:20:00程序设计版块每日发帖之星
日期:2015-09-18 06:20:002015亚冠之阿尔艾因
日期:2015-09-18 10:35:08月度论坛发贴之星
日期:2015-09-30 22:25:002015亚冠之阿尔沙巴布
日期:2015-10-03 08:57:39程序设计版块每日发帖之星
日期:2015-10-05 06:20:00每日论坛发贴之星
日期:2015-10-05 06:20:002015年亚冠纪念徽章
日期:2015-10-06 10:06:482015亚冠之塔什干棉农
日期:2015-10-19 19:43:35程序设计版块每日发帖之星
日期:2015-10-21 06:20:00每日论坛发贴之星
日期:2015-09-14 06:20:00
4 [报告]
发表于 2009-05-11 15:18 |只看该作者
原帖由 MaxWu 于 2009-5-11 14:55 发表
return _("it is based on your username");

这里的下划线是做什么用的呢?

那就是个宏,具体什么作用要看它的定义

BTW, 单从语法看,也可以是个函数。不过 _ 通常是个和 gettext 相关的宏。

[ 本帖最后由 MMMIX 于 2009-5-11 16:49 编辑 ]

论坛徽章:
0
5 [报告]
发表于 2009-05-11 16:09 |只看该作者
补充一下, 是Linux下的, cracklib里面的.
我来查一下是不是Macro.
先谢谢各位.

论坛徽章:
0
6 [报告]
发表于 2009-05-11 16:25 |只看该作者

很多 软件 用这个来 国际化
gettext

论坛徽章:
0
7 [报告]
发表于 2009-05-11 16:26 |只看该作者
windows下肯定没有的 吧,我从来没用过。
定义宽字符是用T或者L吧。你这个没见过。

论坛徽章:
0
8 [报告]
发表于 2009-05-11 16:35 |只看该作者
是个宏,功能看定义

论坛徽章:
0
9 [报告]
发表于 2009-05-11 17:37 |只看该作者
  对,gettext,下面这个message可以做解释.

Re: _() Macro
From: Trevor Johnson <trevor jpj net>
To: Andreas Sliwka <goff nef wh uni-dortmund de>
cc: gtk-app-devel-list redhat com
Subject: Re: _() Macro
Date: Sat, 20 Nov 1999 07:26:36 -0500 (EST)
> Hi,

Hi, Andreas.

>   I jsut read the gnome documentation and found in gnomeabout.html the
>   macro _() (it wasnt defined but used). The corresponding text says:
>  >note that the descriptive text is surrounded by the _(). This will have
>  > the text translated to the the user's language at runtime.
>
>  How is this done? Where do I find more information/documentation about this?

If you have GNU gettext, you can read about it on one of the gettext info
pages:

     Many packages use `_' (a simple underline) as a keyword, and write
  `_("Translatable string"' instead of `gettext ("Translatable
  string"'.  Further, the coding rule, from GNU standards, wanting that
  there is a space between the keyword and the opening parenthesis is
  relaxed, in practice, for this particular usage.  So, the textual
  overhead per translatable string is reduced to only three characters:
  the underline and the two parentheses.  However, even if GNU `gettext'
  uses this convention internally, it does not offer it officially.  The
  real, genuine keyword is truly `gettext' indeed.  It is fairly easy for
  those wanting to use `_' instead of `gettext' to declare:

       #include <libintl.h>
       #define _(String) gettext (String)

  instead of merely using `#include <libintl.h>'.

> mfg

Mit freundlichen gruessen.
__
Trevor Johnson
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP