Resource Wizard
The Resource Wizard prepares your application or applet for translation. It moves hardcoded strings in your application or applet code to ResourceBundles.
ResourceBundles are specialized files that contain a collection of translatable strings. (They may also contain other types of data though this is less common.) A unique resource key identifies each translatable string in the ResourceBundle. The hardcoded string in your application is replaced by a reference to the ResourceBundle and the resource key. This separation of application logic and translatable elements is called resourcing. These separate resource files are then sent to translators.
The Resource Wizard supports the two standard forms of ResourceBundles: ListResourceBundle and
PropertyResourceBundle. PropertyResourceBundles are text files with a .properties extension, and are placed in the same location as the class files for the application or applet. ListResourceBundles are provided as java source files. Because they are implemented as Java source code, new and modified ListResourceBundles need to be recompiled for deployment. With PropertyResourceBundles, there is no need for recompilation when translations are modified or added to the application. ListResourceBundles provide considerably better performance than PropertyResourceBundles.
To display this wizard,
- In the Navigation pane select the .java class file that you want to resource.
- Choose Wizards|Resource Strings.
The Resource Wizard dialog contains the following fields:
Hardcoded String Found
The following fields display the hardcoded string together with the context in which it was found. This helps you to determine which strings to resource.
String
The hardcoded string found by the wizard.
Found In
The line of java source code in which the hardcoded string appears.
Target ResourceBundle
The following options allow you to customize how the string is placed in the ResourceBundle.
ResourceBundle Name
Select the ResourceBundle where the string should be moved to. The drop-down list includes all existing ResourceBundles in your project. To make additional ResourceBundle classes available, click the New button.
If no ResourceBundle is found in your project when you start this wizard, the Create ResourceBundle dialog box displays.
New
Opens the Create ResourceBundle dialog box,
which allows you to create a new resource bundle and make it available to the ResourceBundle Name
drop down list.
Resource Key
Specifies the name of the key that will be used to identify the resourced string. The Resource Wizard automatically suggests a unique name for the key. It makes the suggestion based on the fields Generate Key From String Value or Generate Key From Component and Property Names.
Generate Key From String Value
Specifies that the Resource Wizard suggest a key based on the value of the hardcoded string. For example, if the string is "Click to continue", the suggested key might be "Click_to_continue".
Selecting this option deselects the Generate Key From Component and Property Names option.
Generate Key From Component and Property Names
Specifies that the Resource Wizard suggest a key based on the component and property that the string was used to set. For example, if the string is used in the following line of code:
continueButton.setLabel("Click to continue");
the suggested key might be "continueButton.Label".
Selecting this option deselects the Generate Key From String Value option.
Convert
Moves the string currently displayed in the String field to a ResourceBundle.
Convert All
Moves the current and all remaining hardcoded strings without further prompting.
Skip
Skips the currently displayed hardcoded string without resourcing it, and proceeds to the next hardcoded string.
Cancel
Cancels resourcing of the current hardcoded string and closes the Resource Wizard. Conversions already made are retained.