$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

posted @ 2011-08-31 07:38  规格严格-功夫到家  阅读(832)  评论(0编辑  收藏  举报