Software: Language system


This page describes the details of the language system, that is the way in which the GUI, the Graphical User Interface, can display captions and messages in different languages.  
The routines for this feature are in the module Tye_ModLanguage.BAS

At the start of the program the required language file is read. The data, message numbers and message texts are stored in two arrays.
A call to the function "LangMessage" returns the message text belonging to that number.
For each form (window) of the program a range of message numbers is reserved / available. This will ease the maintenance.
Each form has to set its texts and captions, in the "Form_Load" subroutine. Texts and captions can be changed during subsequent use of the program.

To change the language: Select the desired language in the System window. The program restarts automatically.

Below the definitions of the syntax and usecases are given. 

Call Result = ReadLanguageFile (Path_Filename as string) as integer
Purpose To read a language file, such that the messages can be retreived in a fast way.
Result 0 = ok.
1 = file not found.
2 = file has bad syntax.
Note: it does not make sense to translate these error messages.
Initial Condition Any, including having read another language file before.
Exit Condition The messages are stored in an internal array and are ready for quering.
The global variable "LanguageFileHasBeenRead" will be set tu TRUE if no errors are encountered, Otherwise it will be FALSE.
Possible Error messages See "Result".
Remarks Filename is mandatory.
Path may be absolute or relative. If  omitted the file is read from the current directory. (The program sets the directory with the executable as "current directory")
If the file does not exist or reads with errors, the language will be English.
If no language file has been read many pop-up texts and logging messages will have erroneous texts.



Call Result = LangMessage (MessageNumber as integer) as string.
Purpose To retreive the text of a message in the selected language.
Result The text belonging to the given message number in the selected language.
Initial Condition A language file must have been read succesfully.
Exit Condition n.a.
Possible Error messages Result = "No language file has been read"  if no language file has been succesfully read before.
Result = "Caption xxxx missing" if a non existing message number was given. Note: Although this text is translated too, there will be no crash because of infinite recursion. 
Remarks


File Format for the
language files
DDDD, comma, message text.
*comment text.
DDDD 4 digit message number. Does not need to be consecutive, but preferably ordered from low to high.
comma 1 comma as separator. Must be in the 5th position.
message text The message as it should appear on screen.
The text should fit the destination. Special and accented characters may display depending on the computer systems's locale. 
* Start of a comment line. The asterix must be in the first position.
comment text Comment in the file. This will never appear on screen.
Editing Language files Use a "plain text" editor like Notepad to edit language files. Do not use sophisticated programs like Word.
If you can read it in Notepad with each entry on a seperate line it's ok. 
Ranges currently in use DDDD = 1000 -1099: General error messages and instructions.
DDDD = 1100 -1199: System Window.
DDDD = 1200 -1299: Hearing Threshold.
DDDD = 1300 -1399: A-B-X-test.
DDDD = 1400 -1499: Logarithmic graphical display.
DDDD = 1500 -1599: Directory selection.
DDDD = 1600 - up:   Texts for future expansions. Here is room for hundreds.
DDDD = xx70 - up:     Use thes for messages to be logged.
Remarks If you want to write and publish extensions to this program verify on the website www.breem.nl/TyE how to reserve a range of message numbers.