I don't know anything about internationalization.
I have a project with several packages. I am using Eclipse's built-in "Externalize Strings" wizard to extract String constants in my classes to a properties file and replace those Strings with calls to a static accessor. So instead of
System.out.println("Hello, world!");
I end up with
System.out.println(Messages.getString("MyKey"));
and a Messages
utility class in every package (which provides a static getString
method for getting the desired String from a ResourceBundle [in this case a .properties
file]). Is it best to have a Messages
class in every package, or have a single Messages
class for the entire project?
I'm in favor of a global localization file. You will have duplicate keys ("OK", "Cancel") which would require duplication or nesting, and interfacing with outside localization people is easier if the resources are consolidated.