I'm using ResourceBundle to get strings from MessagesBundle.properties files, but I can't figure out a way to check to make sure all strings called exist (and aren't mistyped) without actually running the program and looking through exceptions. Is there a tool that lets me check this?
You should use one or more classes where entries of your properties files are mapped with public static attributes. Like this everything is checked at compilation time and you avoid later random/unexpected behavior/error.
public class Messages {
public static final String cancel = "cancel";
}
...
Locale locale = new Locale("en", "US");
ResourceBundle labels = ResourceBundle.getBundle("MyBundle", locale);
System.out.println(labels.getString(Messages.cancel));
...
For testing purpose, you can iterate (via reflection) over attributes of the Messages
class and try to load messages from bundles.
At the end: