Definition: I definitely want to have this program able to be internationalized. There are many countries which have bowling lanes and may be able to use this program if it can support their languages. The resulting class should be with static methods so that the internationalized Strings can be accessed anywhere in the program. There are a lot of strings in the program which will require internationalization, so I don't know if I'll put them all in one location/file, or if I'll spread them out in multiple locations/files.
Issue: There is the ResourceBundle and Properties classes in Java that are designed to do this. Unfortunately, they both have some good points and bad. The ResourceBundle, and its accompanying PropertyResourceBundle, are designed to use either a class object or a properties file which is compiled into the .jar file. This makes it impossible for someone to create a localized class or file without having to recompile the program. I prefer to have an external properties file which can then be modified to add a different locale. The Properties class seems best for this as long as I don't use the save options. The Properties class method for retrieving a value String from a key returns null if the key does not exist. I'm not sure if this is best, or an alternative I've seen where "!!" + key + "!!" is returned. This latter seems better because it will eliminate null pointer exceptions, and yet still alert the user that a internationalized string is missing.
Additional: During this process I developed a number of enhancements to the Properties class, embodied in the KeyChain class in the Utilities project. There is also a class called PropertyHelper which provides many static methods to help with using a Properties object.
Required Methods:
|