Separating Strings for Translation

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:

  1. From the Projects page of the Workbench, select the class.

  2. 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.

  3. Specify the type of resource bundle by selecting one of the following radio buttons:

  4. Specify the name of the resource bundle.

  5. 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.

  6. Select OK to proceed with separation.

VisualAge marks each item marked Never Translate image with a special comment. To make a string previously marked Never Translate image 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.

Separating Strings through Property Sheets

To separate String property values as you set them, follow these steps:

  1. Open the property sheet for each embedded bean that contains a text setting.

  2. Select the value field to the right of the property name. A small button Prompter button appears to the right.

  3. 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.

  4. Select the appropriate radio button:

  5. If you selected Do not externalize string, you are finished. Just select OK to close the window.

  6. If you selected Externalize string, specify the type of resource bundle by selecting one of the following radio buttons:

  7. Specify the name of the resource bundle.

    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.

  8. 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.

  9. 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.


Related concepts
Internationalization in VisualAge

Related procedures
Editing Bean Properties

Related references
String Externalization Editor
Externalizing: Package.Class
Example of Code Generated from Visual Composite