### Example of creating an NLS report

This example illustrates how to make the report Coffee Sales.wls in the SampleReports.cat catalog file in `<install_root>\Demo\Reports\SampleReports` displayed in Chinese. It contains the following tasks:

- Task 1: Create an NLS property file
- Task 2: Create a data mapping file
- Task 3: Publish the report to JReport Server
- Task 4: Apply NLS to the report at runtime

#### Task 1: Create an NLS property file

1. Open the report Coffee Sales.wls in the catalog file SampleReports.cat.
2. Select the FilterControl node representing the filter control Product Type in the Report Inspector and set its Map Name property to true. Select the nodes FilterControl1 and FilterControl2 representing the filter controls Category and Product Name respectively in the Report Inspector, you can find that their Map Name property is false.

   If the Map Name property of a filter control is set to true, its title, namely, the name shown in the text box of the Text property is the name shown in the Catalog Browser and cannot be changed, whose type in the NLS Editor will be Metadata. Otherwise, its title shown in the text box of the Text property is editable, and its type in the NLS Editor will be Title.

3. Click Edit > NLS Editor to open the NLS Editor, then click the Add button above the Language box.
4. In the Add Language dialog, select Chinese (China) from the Available Languages list and click OK to add it and return to the NLS Editor.
5. In the Display tab, the scope and types of the objects in the report and items need to be translated are listed in the Scope, Type and Key columns. You can find that only the type of the filter controls Category and Product Name is Title.

6. Give all the corresponding target language text in the Translate in <language> column and click OK.

#### Task 2: Create a data mapping file

1. On the Catalog Browser toolbar, click the Data Mapping Editor button to display the Data Mapping Editor.

2. Click the New button, then in the Create Data Mapping File dialog, type DataMapping in the File Name text box, select Chinese (China) from the Language drop-down list and click OK to return to the Data Mapping Editor.

3. Click the Import Key button. In the Import Key dialog, select the following fields used in the report one by one by pressing the Ctrl button on the keyboard: Country and Region in the Customers table; Category, Product Name and Product Type Name (the Product Type field used in the report) in the Products table. Click OK.

4. Double-click cells in the Map to Value column to specify the mapping values for the imported fields to Chinese. Click OK.

5. Click File > Options. In the Options dialog, select Catalog from the Category box, uncheck the option Forbid editing data object properties, and then click OK.
6. In the Catalog Browser, select the Category field in the Products table, expand the Properties panel on the left, then select DataMapping as the value of its Data Mapping File property.
7. Repeat the step above to set the Data Mapping File property of the fields Product Name and Product Type Name to DataMapping respectively. Click on the Catalog Browser toolbar to save the changes.
8. In the design area, select the chart legend and the Region field in the crosstab and set their Data Mapping File property to DataMapping in the Report Inspector respectively.

   You may notice that the Data Mapping File property can be specified in both the Catalog Browser and the Report Inspector. In JReport, you can specify the data mapping file of a field used in a report both at the catalog level and report level. When the property is specified at both levels, the data mapping file set in the Report Inspector has the higher priority.

9. Save the report.

#### Task 3: Publish the report to JReport Server

Now the NLS property file and corresponding data mapping file are created and applied to the report Coffee Sales.wls. Publish the report and the catalog it uses to JReport Server. For details, refer to Publishing resources remotely.

#### Task 4: Apply NLS to the report at runtime

1. Open a web browser and set the URL to http://localhost:8888, type admin in the User Name and Password text boxes respectively in the Welcome page, and click Login to open the JReport Console page.
2. Click Profile > Customize Server Preferences on the task bar.
3. Switch to the Advanced tab, check the Yes checkbox of the Enable NLS option, and select Chinese (China) from the Default Language drop-down list. Click OK in this dialog and then Click OK in the prompt message dialog.

4. Find the report published just now and click to run it in Web Report Studio. The report is displayed in Chinese.

5. Select Edit Mode from the mode drop-down menu on the Web Report Studio toolbar.

6. Select the chart or the crosstab, the business view it uses is then displayed in the Resources panel. You can see all resources in the resource tree are now displayed as you translated for the metadata objects in the NLS Editor in JReport Designer.