Resource wizard

This is a feature of JBuilder Professional and Enterprise.

The Resource wizard prepares your application or applet for translation. It moves hardcoded strings in your source code files 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 source code. 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,

  1. In the project pane select the .java class file that you want to resource.
  2. Choose Wizards|Resource Strings.


Specify the resource bundle to use

Use this page to specify the name of your ResourceBundle and whether the wizard creates the keys that identify the strings based on the string values or the component and property names.

ResourceBundle Name

Specify the name of the ResourceBundle you want your strings added to. If an existing ResourceBundle exists in your project, the wizard suggests that ResourceBundle. To create a new ResourceBundle, choose New.

New

Opens the Create ResourceBundle dialog box, which allows you to create a new resource bundle. You use this dialog box to specify whether the ResourceBundle is a ListResourceBundle or a PropertyResourceBundle.

Current Source File Only

Resources only the current source file.

Source Files In Current Package

Resources source files in the current package.



Specify the resource key generation method

This is a feature of JBuilder Professional and Enterprise.

Use this step to choose whether the bundle key will be based on the text of the string, the property setting for which it is used, or sequentially.

Resource Key Generation Method

Generate Keys From String Value

Specifies that the Resource Strings 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 Keys From Component and Property Names

Specifies that the Resource Strings wizard suggest a key based on the component and property that the string was used to set. Here is an example:

continueButton.setLabel("Click to continue");

In this example, the suggested key might be "continueButton.Label".

Selecting this option deselects the Generate Key From String Value option.

Generate Keys Sequentially

Generates keys sequentially, using the prefix identifed in the Prefix String field.

Prefix String

The prefix to use when keys are generated sequentially.



Specify which strings to resource

This is a feature of JBuilder Professional and Enterprise.

Use this step to specify which strings the Resource wizard found in your code you want to resource.

The Resource wizard lists all the strings it finds in your code in a table that contains these named columns.

Resource All

Resources the selected strings.

Unresource All

Un-resources the selected strings.

Key

The name given by the wizard that identifies a particular string. You can edit this name if you want.

Value

The string as it appears in your code.

There is a check box to the left of each row in the table. By default, it will be checked, meaning that the string will be resourced. If you don't want the string resourced, uncheck the check box for that row.

When you choose Finish, the wizard creates a ResourceBundle file and adds it to your project.