Skip to main content

Problem:

NLS DS demonstration

Resolution:

INTRODUCTION

==========

This example program demonstrates how to use the National Language Support (NLS) features provided by Net Express and Dialog System. This allows you to create Dialog System screenset files whose text fields will automatically be converted at run-time between 2 or more different languages, i.e., English, French, Spanish, etc.

This is done by creating the screenset using a default language, such as English, and then saving all the screenset text to a NLS file where it can then be translated into other languages. The NLS files are standard ASCII text files that store each different text string within the screenset as a separately numbered line with the text string stored between quotes.

Example:

$set 1

1      "DS NLS Support"              *> Text for Window title.

2      "Name:"                       *> Labels for entry fields.

3      "Street:"                     *>   ""    ""   ""    ""

4      "City:"                       *>   ""    ""   ""    ""

5      "Number:"                     *>   ""    ""   ""    ""

8      "File"                        *> Text for menu item.

9      "Exit"                        *>   ""  ""  ""   ""

16    "OK"                          *> Text for push button.

17    "Exit"                        *>   ""  ""  ""   ""

18    "Message Text"                *> Text for Message Box title.

Dialog System has a "Generate NLS File" option that will automatically scan your screenset and pull these text strings out for you. You then can modify the NLS files, creating one file for each desired language. When you are done editing, you use the Net Express command-line utility, "MSGC", (message compiler), which translates a .NLS text file into a .LNG compiled language format file. You then run the utility "LIBRARY" which will place the newly generated .LNG file into a Net Express .LBR, Library file, so that it can be loaded by the run-time system.

Each file has the same base name with a different 2 digit numeric value appended to it. These digits correspond to a language code which is set in the environment variable "LANG".

Example:

1=American English  

2=Canadian French  

3=Danish  

4=Dutch  

5=English  

6=Finnish  

7=French  

8=German  

9=Italian

10=Norwegian

11=Portugese

12=Spanish

13=Swedish

SOURCE FILES:

=========

Program Files        Description

------------------     -----------------------------------------------------------

TESTNLS.CBL        Program that calls the Dialog System screenset TESTNLS.GS. This program is

                             linked as TESTNLS.EXE.

TESTNLS.GS         Screenset containing one window (WIN-01) with a number of English text labels

                             and corresponding entry fields. It also contains two push buttons. If the "OK"

                             push button is pressed, the message box "MBOX1" will be displayed. If the

                             "Exit" push button is pressed, the program will end.

TESTNLS.CPB       Screenset copybook generated by Dialog System. This contains all the data

                             fields used by the screenset.

TSTNLS01.LBR     Library file containing the English text strings for the screenset file. This file will

                             be recreated as part of the Demo.

TSTNLS07.LBR     Library file containing the French text strings for the screenset file. This file will

                             be recreated as part of the Demo.

REQUIREMENTS:

==========

This sample should run in all environments that have Net Express and Dialog System installed.

OPERATION:

========

To create all necessary files yourself follow these instructions.

1.  From the IDE menu select Tools>Dialog System.

2.  From the Dialog System menu select File>Open and then select TESTNLS.GS from the currently open project. You could have also just double-clicked on TESTNLS.GS in the source pool window.

3.  There is one window (WIN-01) and one message box (MBOX1) defined within this screenset. Take a look at both of these and make a note of the text strings which are being used within these screens.

4.  From the Dialog System menu, select Options>Configuration> Screenset... to open up the configuration window.

5.  In the field labeled "Screenset identifier" enter the text TESTNLS.

6.  In the field labeled "NLS base filename" enter the text TSTNLS. This value will be used when searching for the compiled .LBR files at run-time. The base TSTNLS 2 digit numeric .LBR extension will be used to create the name of the language file. For French, this would be TSTNLS07.LBR.

7.  Under the group "Copy file generation", click the boxes for the options, "Data block flag 88's" and "Data block ANSI constants".

8.  Click the "OK" button to return to Dialog System.

9.  Save the Screenset.

10.  From the Dialog System menu select File>Generate>Data block copyfile... to generate the TESTNLS.CPB file containing data items.

11.  From the Dialog System menu select File>Generate>NLS file... Make sure that the first radio button "Create initial text file and tags" is turned on and click the "Generate" button. This will place all the English text strings into the file TESTNLS.NLS.

12.  Close Dialog System.    

13.  Open up a Net Express 3.1 Command Prompt and make the DSNLS project directory into your current directory.

14.  To create the default English NLS file, from the Net Express Command Prompt enter the following commands: To create the .LNG file:

       RUN MSGC /L TESTNLS.NLS

    To create the .LBR file:

       RUN LIBRARY TESTNLS.LNG=TSTNLS01.LBR

  

15.  To create the French version of this file, from the Net Express Command Prompt start EDIT using TESTNLS.NLS so that you can convert the English text to French:

    Change the following:

     $set 1

     1     "DS NLS Support"

     2     "Name:"

     3     "Street:"

     4     "City:"

     5     "Number:"

     6     "Country:"

     7     "Company:"

     8     "File"

     9     "Exit"

     16    "OK"

     17    "Exit"

     18    "Message Text"

     $

     $set 2

     $

     18    "The OK Button has been Pressed!"

     ---------------------------      to:

     $set 1

     1     "Support NLS pour DS"

     2     "Nom:"

     3     "Rue:"

     4     "Ville:"

     5     "No. de client:"

     6     "Pays:"

     7     "Compagnie:"

     8     "Dossier"

     9     "Quitter"

     16    "OK"

     17    "Quitter"

     18    "Message"

     $

     $set 2

     $

     18    "Vous appuyer sur le bouton OK!"

     -------------------------------------------    

16.  Save the modified file using the EDIT File>Save command.    

17.  To create the French NLS file, from the Net Express Command Prompt enter the following commands:     

     To create the .LNG file:

       RUN MSGC /L TESTNLS.NLS

    To create the .LBR file:

       RUN LIBRARY TESTNLS.LNG=TSTNLS07.LBR    

18.  Delete the files TESTNLS.NLS and TESTNLS.LNG from the project directory.    

19.  Close the Net Express Command Prompt and return to the Net Express IDE. From the IDE menu select Project>Properties and then click on the "IDE..." button under Environment. We need to add two environment variables to the IDE.    

20.  In the "Variable" field enter the value LANG, and in the Value field enter the value 7. Then click the "Set" button to add it to the IDE's environment.    

21.  In the "Variable" field enter the value COBDIR, and in the Value field enter the value between the quotes ".\\;%COBDIR%". Then click the "Set" button to add it to the IDE's environment.    

22.  Click the "OK" button, to return to the previous window and then click its "OK" button to return to the IDE main screen.    

23.  From the IDE menu select Project>Rebuild All, to create the projects .EXE application.   

24.  Click on the Net Express "Run" icon to execute the program. Since we have LANG=7 set in the Project>Properties>IDE environment variables, then the French text strings should replace the English text strings in the screenset when the program is run.    

25.  From the IDE menu select Project>Properties>IDE and change the value of "LANG" to "1" and do another "Rebuild All".    

26.  Run the program again. The text strings should now be displayed in English.

NOTE:

====

If you are running this program from outside the IDE then you need to be sure that the "LANG" environment variable is set correctly. The TSTNLS01.LBR and TSTNLS07.LBR files also need to be available within the COBDIR path setting.

==========================================================

Keywords: demonstration, sample, example, demo, Dialog System, dsnls.zip

demo.ex

demo.ne

Attachments:

dsnls.zip

Old KB# 4224