Adding Localization Code

Add localization code into the application file. The following example is from the SUP101 project.

  1. Open the CustomerSampleScreen.java file in the SUP101Sample project. Add the following code:
    //import resource bundle interface. SUP101SampleResource is the resource bundle interface created automatically
    import com.sybase.sup.samples.objectapi.SUP101SampleResource;
    
  2. Add the following code to the concrete screen code:
    implements SUP101SampleResource
    
    private static ResourceBundle _resources = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);
    
  3. Call the resource bundles string to display user interface text, and change the string to call the resource bundles to display. Add the following code:
    InfoScreen(CustomerSampleScreen sampleScreen, Customer customer)
    {
      _sampleScreen = sampleScreen;
      _customer = customer;
    
      // Set up and display UI elements. Use resource bundle string to display.
      setTitle(_resources.getString(UPDATE_TITLE));
      _fnameField = new BasicEditField(_resources.getString(FIELD_FNAME), customer.getFname(), BasicEditField.DEFAULT_MAXCHARS,Field.FOCUSABLE);
       _lnameField = new BasicEditField(_resources.getString(FIELD_LNAME), customer.getLname(), BasicEditField.DEFAULT_MAXCHARS,Field.FOCUSABLE);
       _companyField = new BasicEditField(_resources.getString(FIELD_COMPANY), customer.getCompany_name(), BasicEditField.DEFAULT_MAXCHARS, Field.FOCUSABLE);
       _addressField = new BasicEditField(_resources.getString(FIELD_ADDRESS), customer.getAddress(), BasicEditField.DEFAULT_MAXCHARS, Field.FOCUSABLE);
       _stateField = new BasicEditField(_resources.getString(FIELD_STATE), customer.getState(), BasicEditField.DEFAULT_MAXCHARS, Field.FOCUSABLE);
       _cityField = new BasicEditField(_resources.getString(FIELD_CITY), customer.getCity(), BasicEditField.DEFAULT_MAXCHARS, Field.FOCUSABLE);
       _phoneField = new BasicEditField(_resources.getString(FIELD_PHONE), customer.getPhone(), BasicEditField.DEFAULT_MAXCHARS, Field.FOCUSABLE);
       _zipField = new BasicEditField(_resources.getString(FIELD_ZIP), customer.getZip(), BasicEditField.DEFAULT_MAXCHARS, Field.FOCUSABLE);