Show TOC Start of Content Area

Procedure documentation Externalizing Strings  Locate the document in its SAP Library structure

 

Caution This procedure alters your original files, not copies. If you want to keep your original, mono-lingual files – for example, for test purposes – back them up now.

Prerequisites

You have created a language-specific project, package, or class that you want to make language-independent.

Procedure

       1.      In the Package Explorer, choose the relevant project, package, or class.

       2.      In the Source menu, choose Find Strings to Externalize.

The system displays all the classes in the project that contain hard-coded text strings.

       3.      Choose the first class in the project.

The system displays the Externalize Strings wizard.

This graphic is explained in the accompanying text
 


For each text string, you can choose to:

¡        Translate: Adds an entry to the properties file, generates a key for it, and substitutes this key for the original string

¡        Never Translate: Marks the string as non-translatable. The wizard will not flag this string as non-translated if you run it again

¡        Skip: Makes no changes to the string. If you run the wizard again, it will flag the string as potentially translatable

       4.      Choose Next. In the dialog that appears, enter a name for your properties file (in the form Resource<component>.properties) and for the resource bundle accessor class.

       5.      Choose Next.

The dialog that appears warns you of any problems that could arise.

       6.      After you are satisfied, choose Next.

The system displays a list of the changes it will make and shows how your source code will look before and after these changes.

       7.      Choose Finish.

The system generates the .properties file and a resource bundle accessor class. It then returns automatically to the list of classes in the project.

       8.      To complete the externalization process, choose each of the classes in turn and repeat the above steps.

The system stores all the strings in the project in a single .properties file.

 

Note If you change or add a string to one of your classes, simply run the wizard again. The system automatically appends the new strings and their keys to the existing .propertiesfile.

 

Result

You now have: a class or set of classes that contain no hard-coded text strings; a single .properties file (which contains all the externalized texts as a set of string/key pairs); and a resource bundle accessor class (contains methods to return the string specified by a given key.)

You can now prepare your .properties file for translation, using the S2X Document Editor.

 

End of Content Area