Before doing this task, please read the conceptual
information listed at the end of this topic.
From the Workbench, you can separate all String values from the class at
once. From the Visual Composition Editor, you can separate String
property values as you set them in the property
sheet.
To separate String values from an entire class at once, follow these
steps:
- From the Projects page of the Workbench, select the class.
- Select Selected and then Externalize Strings.
Alternatively, click mouse button 2 and select Externalize Strings
from the pop-up menu that appears.
The Externalizing: Package.Class window appears, bearing a
list of hardcoded strings found in the class.
- Specify the type of resource bundle by selecting one of the following
radio buttons:
- List resource bundle
- Property resource file
- Specify the name of the resource bundle.
- To choose an existing resource bundle, select the Browse
button, pick a bundle from the standard dialog box, and select
OK.
- To create a new bundle, select New. Enter values as
prompted, depending on the type of resource bundle; select
OK.
- If necessary, mark for exclusion those strings listed under Strings
to be separated that should be left as is. To mark an item,
select the graphic listed to the left of the column, as follows:
If you are not sure of an item, review it in the Context
field.
- Select OK to proceed with separation.
VisualAge marks each item marked
with a special comment. To make a string previously marked
appear in the externalization list once again, find the string inthe code and
delete the comment at the end of the line:
//$NON-NLS-1$. Then perform this task a second time.
To separate String property values as you set them, follow
these steps:
- Open the property sheet for each embedded bean that contains a text
setting.
- Select the value field to the right of the property name. A small
button
appears to the right.
- Select the small button. The String Externalization Editor window
appears. At the top of the window is a set of radio buttons that enable
you to specify how you want VisualAge to handle the text. The current
property setting, if any, appears in the Value field.
- Select the appropriate radio button:
- Do not externalize string
- Externalize string
- If you selected Do not externalize string, you are
finished. Just select OK to close the window.
- If you selected Externalize string, specify the type of
resource bundle by selecting one of the following radio buttons:
- List resource bundle
- Property resource file
- Specify the name of the resource bundle.
- To choose an existing resource bundle, select the Browse
button, pick a bundle from the standard dialog box, and select
OK.
- To create a new bundle, select New. Enter values as
prompted, depending on the type of resource bundle; select
OK.
The name of the bundle appears in the Bundle list. If you
selected an existing class, a currently defined key-value pair appears in
fields below the bundle name.
- To define a resource, type its name in the Key field. If
the resource already exists, the corresponding value for the key appears in
the Value field underneath; otherwise, the field is empty.
To edit the resource, type a new value.
- Select OK to close the window.
The next time you save the class, VisualAge modifies the generated get
methods for the beans whose properties you just set as bundles.
Internationalization in VisualAge
Editing Bean Properties
String Externalization Editor
Externalizing: Package.Class
Example of Code Generated from Visual Composite
