BackPrevious Page Next PageNext

Built-in Functions for NLS

Two built-in Translate functions are available in formulas for applying the NLS feature to the formula result.

The following example shows the usage of the two functions. It is based on the page report List of Customer Contact Cards.cls in the SampleReports.cat catalog file.

  1. Open the page report List of Customer Contact Cards.cls in the catalog SampleReports.cat saved in <install_root>\Demo\Reports\SampleReports.
  2. Preview the report and it displays as follows:

    View the report

  3. Click the Design tab to return to the design mode.
  4. Click View > Language > NLS Editor.
  5. In the NLS Editor, click Add button above the Language box.
  6. In the Add Language dialog, select Chinese (China) from the Available Languages list and click OK to add it to the Language box of the NLS Editor.

    Add Language to NLS Editor

  7. Click OK in the NLS Editor.
  8. Open the Catalog Manager and click Data Mapping Editor on its toolbar.
  9. In the Data Mapping Editor, click the New button.
  10. In the Create Data Mapping File dialog, input DataMapping in the File Name text field and select Chinese (China) from the Language drop-down list. Click OK to go back to the Data Mapping Editor.

    Create Data Mapping File

  11. Click the Import Key button, select the fields City and State in the Customers table of the displayed dialog and click OK.

    Import Key dialog

  12. Double-click cells in the Map to Value column to specify the mapping values for the imported resources in Chinese. Click OK.
  13. Expand Data Source 1 > jdbc connection > Tables > Customers node in the Catalog Manager, select the City column, click the Show Properties button to expand the Properties sheet on the left, then select DataMapping from the Data Mapping File property value drop-down list.

    Make sure that the option Forbid editing data object properties in the Catalog category of the Options dialog is unchecked so that the object property values in the Catalog Manager can be changed.

  14. Repeat the step above to set the Data Mapping File property of the column State in the same table to DataMapping.
  15. Click Save Catalog on the Catalog Manager toolbar to save the changes.
  16. Right-click the formula field CustomerCityStateZip in the report and select Edit Formula from the shortcut menu. The formula is written as below in the Formula Editor:

    CustomerCityStateZip Formula

  17. Edit the formula to Translate(@City) + ", " + Translate(@State) + "  " + Translate(@"Postal Code"), then click Save on the toolbar to save the formula. Close the Formula Editor.

    Rewrite CustomerCityStateZip Formula

    If you have not set the data mapping file of the table columns, you can also edit the formula as follows to apply the NLS feature: Translate("DataMapping", @City)+ ", " +Translate("DataMapping", @State) + "  " + Translate("DataMapping", @"Postal Code").

To make the Chinese characters displayed completely in the report, next we need to edit the font properties for the formula field CustomerCityStateZip.

  1. Select the formula CustomerCityStateZip in the report, then set its Font Face property to SimSun and Font Size property to 12 in the Report Inspector.
  2. Click File > Save to save the report.
  3. Click View > Language > Chinese (China).
  4. Preview the report and you can find the formula result is displayed in Chinese:

    View Translated Report

Notes:

BackPrevious Page Next PageNext