tags:

views:

19

answers:

2

I have realized that through eclipse source code there are a lot of comments like this one, I know they are for instructing eclipse that the strings in these lines aren´t supposed to be internationalizable, and I would like if I can place that kind of single line comments using eclipse code completion assistant.

private String toolTip = ""; //$NON-NLS-1$

A: 

You can enable in Window -> Preferences

Java -> Compiler -> Errors/Warnings -> Code Style -> Non-externalized string missing

01
A: 

The Externalize Strings process can take care of that. Select Source → Externalize Strings. Now, select which Strings you wish to externalize. If you wish to Externalize some of the strings, go ahead. Those which will be marked as "Ignore" will automatically get the //$NON-NLS-1$ comment.

You can quickly add these comments by typing nls and clicking Ctrl+Space (code completion, could be different on your platform). There's a template for NLS with a number you need to enter. You can create a template without a number under the Preferences → Java / Editor / Templates.

You can set Eclipse to automatically remove unnecessary $NON-NLS-1$ comments. See under Preferences → Java / Editor / Save Actions → Enable additional actions → Configure → under Unnecessary code.

zvikico
nls plus autocompletion was the keystroke I was looking for, thank you.
jaime
Glad I could help. Mark this as the right answer using the V sign to the left of the question (you can also vote it up if you wish). Welcome to StackOverflow.
zvikico