Topics: |
To display data in different languages, you must do one of the following:
In either case, if you are using a language that has different alphabets (such as Japanese), make sure that the WebFOCUS Reporting Server and WebFOCUS Client are configured for code page 65001 (Unicode).
You do not need to store most kinds of data in different languages. For example, names, addresses, and numerical data do not require translation. In the case of numerical data, you can easily manage the display format used by the locale at the procedure level.
This appendix describes the steps for creating an application that displays page headings and column titles of a report in different languages, based on a user selection. The following illustrates the reports, in four languages, that the user can request. Notice that the dates and numerical data are formatted according to the conventions of the locale.
Proceed to the next topic for instructions on creating this application.
You can also create a localized application using the LNGPREP function as shown in the following image. For more information, see Creating a Multi-Locale Application Using LNGPREP.
A single, integrated procedure produces the application launch page and the report in different languages. You will mainly use two graphical development tools in App Studio—the Report canvas and the HTML canvas. The Report canvas creates and styles the report, which accesses the MOVIES data source, included in the Legacy Sample Tables and Files tutorial, which you can generate in the WebFOCUS Reporting Server Console. The HTML canvas creates the launch page and links it to the report.
In the sample application, you will prompt the user to select English, French, Spanish, or Portuguese from a drop-down list. The choice corresponds to an amper variable (&LNG) in the procedure. The variable &LNG determines the language of the report.
The procedure will look similar to the following when you are done.
-DEFAULT &LNG = 'EN'; -SET &HEAD = IF &LNG EQ 'EN' THEN 'Movie List' ELSE - IF &LNG EQ 'FR' THEN 'Liste des films' ELSE - IF &LNG EQ 'ES' THEN 'Lista de Cine' ELSE - IF &LNG EQ 'PT' THEN 'Lista de filme'; -SET &FMT = IF &LNG EQ 'EN' THEN '/MDY' ELSE - IF &LNG EQ 'FR' THEN '/DMY' ELSE - IF &LNG EQ 'ES' THEN '/DMY' ELSE - IF &LNG EQ 'PT' THEN '/D-M-Y'; -IF &LNG EQ 'EN' GOTO BEGIN; SET CDN = DOTS_COMMA -BEGIN; USE nls/movies.foc AS MOVIES_&LNG END TABLE FILE MOVIES_&LNG SUM WHOLESALEPR AND LISTPR AND COPIES BY MOVIECODE BY TITLE BY CATEGORY BY DIRECTOR BY RATING BY RELDATE&FMT HEADING "&HEAD" ON TABLE SET PAGE-NUM NOLEAD ON TABLE SET ASNAMES ON ON TABLE NOTOTAL ON TABLE PCHOLD FORMAT HTML ON TABLE SET HTMLEMBEDIMG ON ON TABLE SET HTMLCSS ON ON TABLE SET STYLE * INCLUDE = warm, $ ENDSTYLE END
The column titles of the fields are translated in .lng files, which are generated for each language listed in a .cfg file. This enables you to create procedures localized in a variety of languages from a single Master File. In this example, the movies.mas Master File is localized for French, Spanish, and Portuguese.
The language, decimal notation, and date format are determined by SET commands and controlled by amper variables in the procedure.
WebFOCUS provides many features that make it easy to configure National Language Support (NLS) at your enterprise. Because you translate the .lng files yourself and can generate them for any language for which there is a three-character language code, you are not limited to languages for which there is a WebFOCUS localized version. It is easy to produce many different versions of the same report to accommodate international users.
How to: |
In the example, you will perform the following tasks:
The Create Tutorial Framework page opens.
The Select an Option dialog box opens. Click OK.
A number of sample synonyms are created, including movies.
On first line of syntax in the Master File, just before the dollar sign that is used to end the line, type the following:
DATASET = app/movies.foc,
where:
Is the application folder containing the movies.foc data source. This file was created when you generated the Legacy Sample Tables and Files tutorial.
The full first line of the Master File should now resemble the following:
FILENAME=MOVIES, SUFFIX=FOC, REMARKS='Legacy Metadata Sample: movies (for use with Video Track example)', DATASET= app/movies.foc,$
Your application folder should now contain the following Master Files, all of which are identical:
Each column title should be in the language of the associated Master File.
To rename a field, right-click the name in the Display Name (Title) column of the Business View pane, click Rename, and type in a new name.
Once you have renamed all fields, open the File menu on the ribbon and click Save to save your changes.
Repeat these steps for each of the four Master Files.
Field Name |
moviesEN.mas |
moviesES.mas |
moviesFR.mas |
moviesPT.mas |
---|---|---|---|---|
MOVIECODE |
Movie,Code |
Codigo,Cine |
Code du,Film |
Código,do filme |
TITLE |
Title |
Título |
Titre |
Título |
CATEGORY |
Category |
Categoria |
Catégorie |
Categoria |
DIRECTOR |
Director |
Director |
Directeur |
Diretor |
RATING |
Rating |
Indice |
Classification |
Censura |
RELDATE |
Release,Date |
Fecha de,Estreno |
Date de,Parution |
Data de,produção |
WHOLESALEPR |
Wholesale,Price |
Costo |
Coût |
Preço de,atacado |
LISTPR |
List,Price |
Precio |
Prix |
Preço,de lista |
COPIES |
Copies |
Copia |
Copies |
Cópias |
Once complete, each Master File should now have a TITLE attribute showing the translated column title for each field. You can check by opening each of the modified Master Files as text.
Once your data has been localized, it is easy to use in a procedure, such as a report.
-BEGIN;
-DEFAULT &LNG = 'EN'; -SET &HEAD = IF &LNG EQ 'EN' THEN 'Movie List' ELSE - IF &LNG EQ 'ES' THEN 'Lista de Cine' ELSE - IF &LNG EQ 'FR' THEN 'Liste des films' ELSE - IF &LNG EQ 'PT' THEN 'Lista de filme'; -SET &FMT = IF &LNG EQ 'EN' THEN '/MDY' ELSE - IF &LNG EQ 'ES' THEN '/DMY' ELSE - IF &LNG EQ 'FR' THEN '/DMY' ELSE - IF &LNG EQ 'PT' THEN '/D-M-Y'; -IF &LNG EQ 'EN' GOTO BEGIN;
The line under USE should now look like this:
app/movies.foc AS MOVIES&LNG
where
Is the application folder containing movies.foc. This should already be defined in the report syntax.
and the TABLE FILE declaration should be:
TABLE FILE MOVIES&LNG
The HEADING block of the report syntax should look like the following:
HEADING "&HEAD"
The line containing RELDATE should now look like the following:
BY RELDATE&FMT
You are now ready to create an HTML page with a control to set the &LNG parameter in the report.
You will use an HTML page as a launch page for the report where you can select the language that the report will display.
On the ribbon, on the Components tab, in the Reports group, click Report. Drag your mouse across the page to draw the report container.
Right-click the report container and click Reference existing procedure. Navigate to and select the report created in How to Create a Procedure for Multi-Locale Reporting.
You are alerted that there are undefined parameters in the report. Close any warnings until the New Parameters dialog box displays.
Right-click the value in the Control Type column to change it to Drop Down List if it is not one already. This will allow you to specify the available menu options.
Click OK to create the control.
You can optionally create your own controls using the Controls tab on the ribbon and using the Settings panel to link the control to the &LNG parameter. For more information, see the WebFOCUS App Studio User's Manual.
A group box containing the controls appears on the page. You can modify any of the elements that it contains, such as resizing any of the components.
By default, this menu only shows EN, since this was set as the default. You can add the other values to the menu and set the display values to show the names of each language.
Your page is complete. When you run the page, making a selection from the drop-down menu and clicking the run button on the HTML page should reload the report in the selected language, with localized column titles, date format, and page heading.
WebFOCUS | |
Feedback |