Extending the resource bundle and properties files

In this lesson, you are creating a properties file that contains the text for the warranty term column for Management Center. A properties file is a resource bundle that contains translatable text that displays in the user interface. Resource bundles contain locale-specific objects. By using resource bundle files, the text can be easily translated into different languages.

Procedure

  1. Create a properties file to include the warranty text to display in Management Center and in your store:
    1. In the Enterprise Explorer view, go to LOBTools > Java Resources: src
    2. Right-click Java Resources: src, click New > Package.
    3. In the Name field, enter com.mycompany.commerce.catalog.client.lobtools.properties.
    4. Click Finish. The new package com.mycompany.commerce.catalog.client.lobtools.properties is created.
    5. Right-click the com.mycompany.commerce.catalog.client.lobtools.properties package and click New > Other > General > File and click Next.
    6. In the File name field, enter CatalogLOB_en_US.properties, click Finish. The CatalogLOB_en_US.properties file opens.
    7. Define the properties for the warranty text to display:
      productWarranty_ColumnHeader=WarrantyTerm
      productWarranty_TabHeader=Warranty
      productWarranty_GroupTitleForWarranty=Warranty Information
      productWarranty_WarrantyTermPrompt=Warranty Term
      productWarranty_WarrantyTypePrompt=Warranty Type
      productWarranty_DisplayNameForTerm1=30 days
      productWarranty_DisplayNameForTerm2=45 days
      productWarranty_DisplayNameForTerm3=60 days
      productWarranty_DisplayNameForType1=limited
      productWarranty_DisplayNameForType2=comprehensive
      productWarranty_GroupTitleForOthers=Care Instruction
      productWarranty_OtherPrompt=CareInstruction 
      Note: WarrantyTerm is used in this lesson. The other properties are used in subsequent tutorial lessons.
    8. Create a duplicate of CatalogLOB_en_US.properties and name it CatalogLOB.properties.
  2. Register the new property file in the resource bundle:
    1. In the Enterprise Explorer view, go to LOBTools > WebContent > WEB-INF > src > lzx.
    2. Right-click lzx and select New > Folder.
    3. In the Folder name field, enter mycompany and click Finish.
    4. Right-click mycompany and select New > Folder.
    5. In the Folder name field, enter catalog and click Finish.
    6. Right-click catalog and select New > File.
    7. In the File name field, enter extCatalogManagementResourceBundle.lzx.
    8. Click Finish. The extCatalogManagementResourceBundle.lzx file opens.
    9. Add the following code to the file:
      <library>
      	<class name="extCatalogResourceBundle" extends="wcfResourceBundle" baseName="com.mycompany.commerce.catalog.client.lobtools.properties.CatalogLOB">
      		<wcfResourceBundleKey name="productWarranty_ColumnHeader"/>
      		<wcfResourceBundleKey name="productWarranty_TabHeader"/>
      		<wcfResourceBundleKey name="productWarranty_GroupTitleForWarranty"/>
      		<wcfResourceBundleKey name="productWarranty_GroupTitleForOthers"/>
      		<wcfResourceBundleKey name="productWarranty_WarrantyTermPrompt"/>
      		<wcfResourceBundleKey name="productWarranty_WarrantyTypePrompt"/>
      		<wcfResourceBundleKey name="productWarranty_OtherPrompt"/>
      		<wcfResourceBundleKey name="productWarranty_DisplayNameForTerm1"/>
      		<wcfResourceBundleKey name="productWarranty_DisplayNameForTerm2"/>
      		<wcfResourceBundleKey name="productWarranty_DisplayNameForTerm3"/>
      		<wcfResourceBundleKey name="productWarranty_DisplayNameForType1"/>
      		<wcfResourceBundleKey name="productWarranty_DisplayNameForType2"/>
      	</class>
      	<extCatalogResourceBundle id="extCatalogResources"/>
      </library>
      

      Use of the extCatalogResources id is referenced in the Management Center definition files on the next page of this tutorial.

    10. Save and close the file.
  3. Include the extCatalogManagementResourceBundle.lzx file so that it is available to use.
    1. In the Enterprise Explorer view, go to LOBTools > WebContent > WEB-INF > src > lzx > commerce > catalog.
    2. Open the CatalogExtensionsLibrary.lzx file.
    3. Update the file to include the following code to point to the customized resource bundle file:
      <library> 
      
      <!-- File to add customer libraries -->
      <include href="../../mycompany/catalog/extCatalogManagementResourceBundle.lzx"/>
      </library>
    4. Click Save.
    5. Right-click LOBTools Project; then click Build OpenLaszlo Project to produce an updated ManagementCenter.swf file under the workspace_dir\LOBTools\WebContent directory. This directory is the default environment setting.