[jsword-devel] Externalizing Strings

Joe Walker jsword-devel@crosswire.org
Tue, 06 Apr 2004 23:35:36 +0100


Unless anyone disagrees I'm going to apply this patch.
Please shout now.

Looking at the other patch you sent this evening, DM, there are 2 ways 
to avoid i18n warnings from eclipse, one is to do the $NON_NLS thing and 
the other is to declare a "public static final String".

I doubt very much that other IDEs will conflict with eclipse on this. My 
research leads me to the conclusion that Eclipse are well out in front 
on this.

 From my perspective the "public static final String" is more work, but 
less standard. I don't really have any strong feelings on which is 
better. If you have an opinion, shout and well do that.

Joe.


DM Smith wrote:
> I  have attached a patch for evaluation. I don't mean for it to be 
> checked in unless there is general agreement that this is an approach we 
> want to pursue.
> 
> Eclipse has decent support for externalizing strings.
> 
> With developer cooperation, it also can help by flagging strings that 
> need to be externalized.
> 
> The developer cooperation is to add //$NON-NLS-n$ as an end of line 
> comment where n stands for the string that does not need to be 
> internationalized. If there are more than one string then add more of 
> these comments to the end of the line.
> 
> For a contrived example:
> 
> System.out.println("Hello " + System.getProperty("user.name") + ". 
> Welcome to " + appName); //$NON-NLS-2$
> 
> Or
> 
> System.out.println( "(" + action + ") " + reason + " at this time"); 
> //$NON-NLS-1$ //$NON-NLS-2$
> 
> When there are strings all through the code it really begins to look 
> ugly, but if all non-externalized strings are declared as:
>   [public|protected|private] static final XXX="value"; //$NON-NLS-1
> It won't look so bad.
> 
> Then you can go to Window->Preferences->Java->Compiler->Advanced
> and set the "Usage of non-externalized strings" to something other than 
> ignore.
> Then click on Apply and say yes to recompiling.
> 
> I am including a patch for java/swing that marks all of the strings that 
> don't need to be internationalized. You will find that there are about 
> 200 strings that need to be externalized in the GUI.
> 
> If you look closely, I marked all strings that a user will not see as 
> NON-NLS. Strings that a user will or might see, I left as needing 
> externalization.
> 
> If we were to use this as a way of managing the strings, then a 
> gatekeeper could be the one to validate that all strings are externalized.
> 
> _________________________________________________________________
> Limited-time offer: Fast, reliable MSN 9 Dial-up Internet access FREE 
> for 2 months! 
> http://join.msn.com/?page=dept/dialup&pgmarket=en-us&ST=1/go/onm00200361ave/direct/01/ 
>