The Company
Products
Solutions
Services and Support
Customers
Partners
News
Events
Home >> News >> WebFOCUS Newsletter >> February 2004 >> Global Watch: Building the Tower of Babel…Successfully

Global Watch: Building the Tower of Babel…Successfully

By Genevieve Monet

The 21st century is a time of international collaboration. The European Community and the North American Free Trade Act (NAFTA) encourage people of different countries to work together. The accrued markets that result from these associations are interesting business terrain.

Information is an important resource and in order to share and expand it we have to understand it. Remember the lesson from the Tower of Babel: nothing is accomplished without effective communication. A lot of information is stored in databases and our business is often to collect this data and display it in a meaningful way. But we can only inform those who can understand us.

It is not difficult to provide your users with data in the language of their choice. Here are some tips that will help you accomplish this.

Multilingual Data

If you want to display data in different languages, the data has to be entered in those languages. There’s nothing magical about that. You may use a different database for each language or put everything in the same database. In that case, each record would contain a field that indicates its language and the report request would test this indicator to retrieve the record in the chosen language. In either case, if you are dealing with different alphabets (such as Japanese) you should use Unicode, which provides a unique number for every character regardless of language, platform, or program.

This can be quite a project, so keep in mind that most data does not need to exist in many languages. Names, addresses, and numerical data are examples of information that does not need to be translated. In the case of numerical data the display format can be managed easily at the FOCEXEC level.

How It Works

First, we ask the user for his or her choice of English, French, Spanish, or Portuguese with a drop-down list box. The choice corresponds to the amper variable &LNG that will determine the language of the report.

A simple FOCEXEC will produce the report in all the languages using the sample FOCUS file MOVIES (see Figure 1). This FOCEXEC is mostly created with the GUI tools – Report Painter, Resource Layout Painter.

-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' ELSE	
-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' ELSE
_IF &LNG EQ 'EN' GOTO BEGIN;
SET CDN = ON
-BEGIN
USE
D:\IBI\APPS\LANGUES\MOVIE.FOC AS MOVIES&LNG
END
TABLE FILE MOVIES&LNG
PRINT
.
     RELDATE&FMT
.
. HEADING
"&HEAD"
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOAL 
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
.
.
.
ON TABLE HOLD AS ITEM31 FORMAT HTMTABLE
END
-HTMLFORM Launch

Figure 1

The column titles of the fields are controlled by the title attribute in the FOCUS Master File Description (MFD). The title attribute determines the column title that will be displayed for that field. It can be overridden at the FOCEXEC level. The heading, date format, and language selection are controlled by amper variables entered manually. We have a different master for each language with the appropriate column titles. In this case, there are four: English, French, Spanish, and Portuguese.

The Steps

1. You may create a new application or use an existing one. Make sure the ibisamp directory is in the search path of the application. Click on Masters. Add the "Movies" master to the project and make four copies. Then right-click each copy and rename them as follows: moviesEN.mas, moviesFR.mas, moviesES.mas, and moviesPT.mas.
2. Double-click on the moviesEN.mas file. In the Master File Editor, select the field MOVIECODE in the left panel, then click on the display tab in the right panel. Enter Movie,code in the Column Title text box. Enter the text as shown in the table on Figure 2, for each field, in each master. Each time you exit the Master File Editor you will be prompted to create a new file. Answer No.

Field Name moviesEN.mas moviesFR.mas moviesES.mas moviesPT.mas
MOVIECODE Movie,Code Code du,Film Codigo,Cine Codigo,do filme
TITLE Title Titre Titulo Titulo
CATEGORY Category Catégorie Categoria Categoria
DIRECTOR Director Directeur Director Director
RATING Rating Classi-,fication Indice Censura
RELDATE Release,Date Date de,Parution Fecha de,Estreno Data de,produçào
WHOLESALER Cost Coût Costo Preç de, atacado
LISTPR List,Price Prix Precio Preç, de lista
COPIES Copies Copies Copia Cópias

Figure 2

3. Right-click on the procedures folder in the left panel and create a new procedure using the moviesEN master. First, we’ll add a use statement associating movies.foc file to the moviesEN master. In the Painter, click on the window menu and select the procedure list window.
4. While in the procedure window click on the connector left of the report and select the use tool. Browse for the movies.foc file and enter the master name moviesEN in the Master File area.
5. We will also add a set command to display numerical data with a comma as the decimal separator because this is how numbers are displayed in France, Spain and Portugal. Click on the connector to the left of the use and choose the Set tool. Double-click the CDN (for Continental Decimal Notation) setting in the "Available Settings" area and set it to ON in the "Current Value" list.
6. Exit the Set tool. Click on the window menu and return to the Painter window (number 3 on the list). Double-click each field from the left panel so that it is added in the report in right panel. Add the heading "Movie List." Style the report as you wish. You should make all your changes to the styling at this point. It will not be possible to return to the Painter after the next steps.
7. You will now be on the procedure window. Click on the connector between the Set and the Use and choose the Other tool to add a label. This label will allow us to skip the Set command for the English report. Enter the text:
-BEGIN;
8. Click on the connector left of the set command and choose the Other tool. We will add a few amper variables: &LNG for the language of the report, &HEAD for the heading and &FMT for the format of the date. Enter the following text:
-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;
9. Exit the procedure window. In the right panel of the explorer, right-click the procedure list.fex and choose “Edit as Text.” A window containing all the code for the procedure will open. Replace MOVIESEN in the Use and the Report with MOVIES&LNG. This will allow using the different master files according to the language chosen by the user. Also change the Heading from "Movies List" to "&HEAD" and the field RELDATE to RELDATE&FMT.
10. Right-click the procedure folder in the left panel and create a new procedure but make sure to select Resource Layout Painter in the "Create in" field.
11. From the insert menu select "import existing procedure" and choose the list.fex procedure. Click OK. The Resource Layout will contain three text boxes for &LNG, a submit button, a reset button, and a report icon. Delete the text boxes &HEAD and &FMT. You can modify the properties of these objects in the properties window on the upper right part of the screen. Click on the reset button and press delete. Click the submit button and reposition it to the right of the text box. Resize the report icon to fill up the area under the text box and button.
12. Click on the text box. Change it to a drop-down list box by clicking in the "Control Type" cell on the first line of the parameters area. Then add the four possible values in the corresponding boxes as shown in Figure 3 and make ENGLISH the selected value. Exit and update the procedure. Now test your work by running the procedure Launch.fex and selecting different languages to affect the displayed report.

Value Display
EN ENGLISH
FR FRANCAIS
ES ESPANOL
PT PORTUGUES

Figure 3

Congratulations! You have created a multilingual application.

WebFOCUS has come a long way with National Language support and versions. However, as this application demonstrates with the Portuguese report, we are not limited to the languages supported by our product. It is easy to produce many different versions of the same report to accommodate international users and start building wonders.