3

does anybody know if it is possible to set one //$NON-NLS annotation tag in java for all Strings in one line... maybe like this:

String[][] info = new String[][]{
     {"a1", "a2"}, {"b1", "b2"}, {"c1", "c2"}, {"d1", "d2"} //$NON-NLS-ALL$
};       

I like to prevent this long line of code:

String[][] info = new String[][]{
     {"a1", "a2"}, {"b1", "b2"}, {"c1", "c2"}, {"d1", "d2"} //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
};

thanks

Jimi Jimbo
  • 31
  • 5

2 Answers2

6

I don't think you can make this work with the //$NON-NLS comments, but you can suppress the NLS warnings for the whole variable declaration:

@SuppressWarnings("nls")
String[][] info = new String[][] {
    {"a1", "a2"}, {"b1", "b2"}, {"c1", "c2"}, {"d1", "d2"}
};      
Natix
  • 14,017
  • 7
  • 54
  • 69
2

You can instruct to ignore all by adding //$NON-NLS-L$

sabadow
  • 5,095
  • 3
  • 34
  • 51
Anand
  • 21
  • 3
  • Actually it does answer the question, but that -L only works in globalyzer, not in eclipse: http://www.lingoport.com/software-internationalization-products/globalyzer/. So the answer is technically wrong, but well intentioned. Voting back up. – Rhubarb Nov 14 '14 at 12:51