ProblemYou have existing code that contains hardcoded strings. SolutionUse JILT, Eclipse, or your favorite IDE. DiscussionMany tools extract Strings into resource bundles. This process is also known as externalization . Nothing to do with jilting your lover, JILT is Sun's Java Internationalization and Localization Toolkit, Version 2.0.[1] JILTing your code means processing it with JILT, which facilitates I18N and L10N'ing the Java classes. JILT has four GUI-based tools, which can be used independently, started from a GUI frontend called JILKIT. Figure 15-1 shows JILT in action.
Figure 15-1. JILT in actionThe tools are listed in Table 15-2.
It's worth noting that the time it takes to learn these tools may overshadow their benefits on small projects, but on large projects they will likely prove worthwhile. Version 2 of the Translator ships with a Chinese dictionary, but you can provide your own dictionaries as well. The Java Internationalization and Localization Toolkit is nearing its end-of-life support from Sun but can, as of this writing, still be downloaded for free from Sun's Java page, http://java.sun.com/products/jilkit/. Many IDEs provide an externalization mechanism. Under Eclipse, for example, select a Java source file, then select Externalize Strings from the Source menu. Eclipse generates a Properties file and a class with static methods to retrieve the values of the Strings and replace the strings in your code with calls to those methods. Other IDEs provide similar mechanisms. |