Ultra Light Client Guide and Reference

Implementing NLS support for ULC applications

If you have chosen to create Unicode-encoded files, you must install the JDK first. You will use the JDK's native2ascii utility program to convert native encoding to Unicode. For more information about this utility program, see http://www.javasoft.com/products/jdk/1.2/docs/tooldocs/win32/native2ascii.html.

Next, follow these steps in VisualAge:

  1. Implement the #abtExternalizedStringBuildingInfo method in the startup class for your ULC-based application, as follows:
    SomeClass class>>#abtExternalizedStringBuildingInfo 
     
       ^Array 
           with: 'ULC?R40'  "MPR filename without extension; use yours here" 
           with: false      "NOT platform dependent" 
           with: true.      "DO recurse subApplications" 
    

    The question mark (?) in the file name is a placeholder for the locale strings mapped in #initializeUlcSystemNLSMappings later in this process.

  2. From the System Transcript window, generate a TRA file for the default language environment. Select Tools->NLS Tools->Generate TRA.
  3. Generate a MPR file for the default language environment. Select Tools->NLS Tools->Generate Default Language MPR.
  4. Replicate and translate a TRA file for each additional language you want the application to support.
  5. From a command prompt, convert the TRA files to Unicode with the native2ascii utility program found in the JDK.

    Important: Skip this step if you do not wish to use Unicode or if the default language environment is Latin-1 (code page 850 or ISO 8559-1).

    For example, the following syntax converts a Japanese input file to Unicode:

    native2ascii -encoding Cp942 input.tra output.tra
    
  6. From the System Transcript window, generate MPR files for environments other than the default:
  7. Make sure to place the MPR files in a directory contained in your NLS path, or in the same directory as the image.
  8. Write the initialization script for locale mappings, as follows:
    SomeClass class>>#initializeUlcSystemNLSMappings
                
       UlcSystem default
       nlsMapDefault: 'en' to: UlcNlsFileEnglish;
       nlsMappings: (
          LookupTable new
             at: 'en' put: UlcNlsFileEnglish;
             at: 'de' put: UlcNlsFileGerman;
             yourself)
    

    In this method, the ISO language code de is mapped to the string specified in UlcNlsFileGerman. This string is substituted into the name of the MPR file established for a German locale in the #abtExternalizedStringBuildingInfo method.

  9. Call this method in loaded, a method in the startup class:
    loaded
     
       UlcSystem isRuntime ifTrue: [self initializeUlcSystemNLSMappings].
       UlcSystem registerApplicationNamed: 'MyUlcApp' withStartupClass: SomeClass
    

    For more information on registration during startup, see Registering the ULC visual application class.

UlcAlert is the only class shipped with ULC that uses string resources according to this scheme. The abstract MPR file name is ulcwi?40. Its language-to-file-name substitution mappings follow the standard values described in the VisualAge User's Guide. To implement a different mapping, adjust the definitions for the widget strings to match those of the application.

The language mappings shipped with ULC correspond to those languages for which a national language version of VisualAge is available, with the addition of German. For any other languages, you must include TRA and MPR files. The names and scripts for their generation can be found in the UlcWidgetApp class categorized under ULC-Internal-NLS Support.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]