Quick Start: Internationalization

Overview

  1. Create the properties files containing the localized text for your application.
  2. Use the Configuration Context of the EchoStudio Form Editor to set the resource path for the ResourceBundle.
  3. Switch to the Design Context.
  4. For all internationalized components, change the appropriate Bean property to the resource's key, preceeded by a %. (For example, you might set the text property of a Label to %errorMessage.text.)

Video

View the short video walkthrough (980k, 2:17) to observe the techniques described in this section.

Details

If you are new to internationalization or Java's ResourceBundle, you may benefit from reviewing Sun's Internationalization Tutorial and the ResourceBundle JavaDoc.

Use the Eclipse Package Explorer to find the loginscreendemo package in your project. Right-click on the package name to open the context menu, then choose New, then File. (Figure 1) The New File window is displayed with the appropriate destination folder already selected. (Figure 2) Enter LoginScreenBundle.properties for the file name and click OK. Eclipse opens the file for you to edit. Copy the contents of this file into the new file and save it. (Figure 3)

Repeat the above steps for another file, named LoginScreenBundle_fr.properties. The _fr tells Java that this resource bundle is to be used for the French locale. Copy the contents of this file into the new file and save it.

Open the LoginScreen form component using the EchoStudio Project Overview, as described in previous chapters. Find the tabs in the lower-left and click the Configuration tab. (Figure 4) EchoStudio presents you with the Configuration Context. (Figure 5) Use the Browse... button to select the LoginScreenBundle.properties file. (Figure 6)

Switch to the Design Context using the Design tab in the lower-left. If necessary, switch the Component Editor in the bottom left to edit properties by clicking the Properties tab above it. Select the "Password:" Label and change its text property to %passwordPrompt.text. (Figure 7) Next, select the "Username:" Label and change its text property to %usernamePrompt.text. Finally, select the error message Label and change its text property to %errorMessage.text.

Save the LoginScreen. Find the locale selector in the upper-left of the Eclipse window and select the fr locale. (Figure 8) Hit [Enter] after you have selected it to notify EchoStudio of the change. The preview now displays the LoginScreen using the text from the French locale ResourceBundle we defined. (Figure 9)

Using Internationalization for Reusability

Internationalization can be used to make your components more reusable. For example, our LoginScreen uses the prompt "Username:" to request the name by which the user will be identified. Another common prompt for that information is "Login:". By placing the text outside of the compiled class files, you make it easier for others to change the text without editing your source code.



< Screen NavigationUsing Styles >

Figure 1
Figure 1

Figure 2
Figure 2

Figure 3
Figure 3

Figure 4
Figure 4

Figure 5
Figure 5

Figure 6
Figure 6

Figure 7
Figure 7

Figure 8
Figure 8

Figure 9
Figure 9