$NON-NLS-1$(转载几篇解惑)

Look at this snap:

public static String valueOf(boolean value) {   
        return value ? "true" : "false"; //$NON-NLS-1$ //$NON-NLS-2$
}    

What is "//$NON-NLS-1$ //$NON-NLS-2$" mean ?

It's used by Eclipse to indicate that a string doesn't need to be translated, probably because it's not going to be seen by the application's users. Netbeans uses NOI18N for the same purpose.

If you don't add that, you'll get a compiler warning. It doesn't stop your code from compiling into a valid class file, but it tells you that you may be doing something undesirable. You are free to ignore the warning. But if you don't want to see it at all--perhaps because too many warnings about something that you're doing on purpose clutters up the output and obscures warnings you do care--then you can add that $NON-NLS-1$ to tell the compiler not to produce the warning.

It's just about fine-tuning which warnings you do and do not care to see.

 

http://my.oschina.net/zengsai/blog/6305

 

--------------------------------------------------------------------------

最近写了很多junit test case, 很多方法的参数用了“XXX”。
组织上要求我把这些不需要国际化的参数后面加上注释//$NON-NLS-1$。
问:有什么办法可以自动加上,因为要改的文件实在太多了,我手动加体力不支吃不消。。。

------------------------------------------------------------------------------------------------------------------
问题补充:

moyan_java 写道
Eclipse里面,Search ->  Search --> 填入需要替换的字符,如"XXX",--->点击Replace按钮,在With框中填入"XXX"  //$NON-NLS-1$ 点击OK即可.
希望能帮到你。




找到啦,Source-Externalize Strings  把所有不需要国际化的String参数都ignore掉 next or finish

不过还是很感谢这位老兄~

 

--------------------------------------------------------------------------

http://stackoverflow.com/questions/3593771/how-to-place-non-nls-1-kind-of-comments-in-eclipse

 

http://stackoverflow.com/questions/654037/what-does-non-nls-1-mean

 

http://blog.csdn.net/mr_yanfei/article/details/47271

转载于:https://www.cnblogs.com/diyunpeng/archive/2011/08/31/2160250.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值