Home | OS/2 Software | Rexx | NLS Support for VisPro/Rexx applications

NLS Support for VisPro/Rexx applications

Contributed by: Joachim Scholtysik

Here is a sample of the NLS programming im my programs Alarm and Charmap. I have used the Resource Editor and an inifile to change the language in my programs. After creating the form I built the RESSOURCE.VPR with an editor (The Resource Editor seems to have a bug with the Shift key) :

The language sample code is included in the zipfile "LANGUAGE.ZIP". To unpack the zipfile, please use the -d option to restore the subdirectories with PKZIP.


 


STRINGTABLE
  BEGIN
     6000, "~Datei"
     6001, "~Bearbeiten"
     6002, "~Ende"
     6003, "~Sprache"
     6004, "Testzeile 1"
     6100, "~File"
     6101, "E~dit"
     6102, "~End"
     6103, "~Language"
     6104, "Test Line 1"
  END

As you can see, all entries between 6000 and 6099 are for the german language and all entries between 6100 and 6199 are for the english language. But you can expand the ranges as you like it.

Then I create the inifile with an application called 'Dialog', a key 'Nummer' and a value of '6000'. This means when the program reads from the inifile, it gets the value '6000' that means that it shall start with german language.

In my main form I then create a 'When opened' event that contains the
following lines :

/* Event Form events, Opened */
Arg window

/* Load REXXUTIL */
CALL RxFuncAdd 'SysLoadFuncs','Rexxutil','SysLoadFuncs'
CALL SysLoadFuncs

/* Set the path for the inifile */
/* Get actual directory */
dir = directory()
/* Inifile is in the actual directory */           
inifile = dir || "\NUMMER.INI"

/* Read the value for the language */
/* 6000 = german, 6100 = english */
i = SysIni(inifile, "Dialog", "Nummer")    

/* Read the value for the menuitem File = Datei etc. */
file=VpWindow(window, 'LOADSTRING',i)
edit=VpWindow(window, 'LOADSTRING',i+1)    
end=VpWindow(window, 'LOADSTRING',i+2)     
language=VpWindow(window, 'LOADSTRING',i+3)
line=VpWindow(window, 'LOADSTRING',i+4)    

/* Set the value for the menuitem Edit = Bearbeiten etc. */
CALL VpSetItemValue window,256,file
CALL VpSetItemValue window,257,edit     
CALL VpSetItemValue window,258,end     
CALL VpSetItemValue window,259,language    
CALL VpSetItemValue window,1000,line     


For the menuitem 'Sprache' = 'Language' i create a menu event that
contains the following lines :

/* Event Menu events, ~Sprache */
Arg window self

/* Read the value for the language */
/* 6000 = german, 6100 = english */
nummer = SysIni(inifile, "Dialog", "Nummer")
/* If german language is set in the inifile, then change to english
language, else vice versa */
if nummer = 6000 then do
  i = 6100
end
else do
  i = 6000
end

/* Read the value for the menuitem File = Datei */
file=VpWindow(window, 'LOADSTRING',i)
edit=VpWindow(window, 'LOADSTRING',i+1)
end=VpWindow(window, 'LOADSTRING',i+2)
language=VpWindow(window, 'LOADSTRING',i+3)
line=VpWindow(window, 'LOADSTRING',i+4)


/* Set the value for the menuitem File = Datei */
CALL VpSetItemValue window,256,file
CALL VpSetItemValue window,257,edit
CALL VpSetItemValue window,258,end
CALL VpSetItemValue window,259,language
CALL VpSetItemValue window,1000,line

/Write the new value back into the inifile */
CALL SysIni inifile, "Dialog", "Nummer", i

That is all you need to build NLS into your programs. The RESOURCE.VPR
can now be expanded with all the languages you need.