- Constructing the Login Page
- Translating the Site
- Creating the Resource Bundle
- Conclusions
Creating the Resource Bundle
Now that we have a reliable way to translate the prototype, we are ready to produce the English and Spanish resource bundles. Using AltaVista, we can quickly translate the key phrases, listed previously, into Spanish. The Spanish translation is shown here:
Por favor Conexión Identificación del usuario: Contraseña: Conexión Inglés Español Chino
You now have enough information to create the English and Spanish resource bundles. (A resource bundle is just a regular Java class file.) The English and Spanish resource bundles are shown in Listing 2 and Listing 3 at the end of the article.
To create the Chinese resource bundle, you must take a few extra steps. First, you can't use a regular ASCII editor such as Notepadyou must use an editor that is capable of displaying the UNICODE characters. For this example, we will use the WordPad editor that comes with Microsoft Windows. Figure 2 shows the Chinese resource bundle being edited by WordPad. All that I did to produce these Chinese characters was copy and paste them from AltaVista.
Figure 2 Editing the Chinese resource bundle.
Now that you have created the resource bundles, you must compile them and place them into a JAR file. The series of commands that I used to build these files is the following:
javac -encoding UTF-16 ./com/heaton/informit/I18NBundle_zh.java javac ./com/heaton/informit/I18NBundle_es.java javac ./com/heaton/informit/I18NBundle.java javac ./com/heaton/informit/I18NBundle_en.java jar cvf I18NBundle.jar ./com/heaton/informit/*.class
Notice that for the Chinese file that I had to specify the encoding to the Java compiler. Do not forget this step when compiling Java source files that contain UNICODE characters. This will produce a JAR file that contains your resource bundles. You should place this file into your webserver's lib directory.