I started the first time, adding a Multilanguage-option to a App.
First I wanted to use a DBF, but now I found a better Solution.
How it works ( Sample ) :
1.
Define a Static Var cLang[40] // contains the needed Keywords
2.
Array-Init
I := 1
FOR i := 1 TO 40
cLang[I] := " "
NEXT
3.
Load on Top of Your App
GET_LANG() // Get Keywords from INI
4.
Get Keywords from INI
- Code: Select all Expand view
// --------- INI - Read -------------
FUNCTION GET_LANG()
Local oInifile
IF !FILE ( c_path + "\LANGUAGE.ini" )
SAVE_LANG()
ELSE
INI oInifile FILE c_path + "\LANGUAGE.INI"
GET cLang[1] SECTION "Language" ENTRY "Game" OF oInifile DEFAULT "Game"
GET cLang[2] SECTION "Language" ENTRY "Trials" OF oInifile DEFAULT "Trials"
GET cLang[3] SECTION "Language" ENTRY "Scores" OF oInifile DEFAULT "Scores"
GET cLang[4] SECTION "Language" ENTRY "Select" OF oInifile DEFAULT "Select"
GET cLang[5] SECTION "Language" ENTRY "Player" OF oInifile DEFAULT "Player"
GET cLang[6] SECTION "Language" ENTRY "Training" OF oInifile DEFAULT "Training"
...
...
GET cLang[14] SECTION "Language" ENTRY "There are missing" OF oInifile DEFAULT "There are missing"
...
...
ENDINI
ENDIF
RETURN( NIL )
5.
If not exist, create a new LANGUAGE.INI ( English )
- Code: Select all Expand view
FUNCTION SAVE_LANG()
LOCAL lSysini := .T., cIniFile := c_Path + "\LANGUAGE.INI"
WritePProString( "Language", "Game", "Game", cIniFile )
WritePProString( "Language", "Trials", "Trials", cIniFile )
WritePProString( "Language", "Scores", "Scores", cIniFile )
WritePProString( "Language", "Select", "Select", cIniFile )
WritePProString( "Language", "Player", "Player", cIniFile )
WritePProString( "Language", "Training", "&Training", cIniFile )
WritePProString( "Language", "Reset", "Reset", cIniFile )
WritePProString( "Language", "Config", "Config", cIniFile )
WritePProString( "Language", "Create", "Create", cIniFile )
WritePProString( "Language", "Show", "Show", cIniFile )
WritePProString( "Language", "Next", "&Next", cIniFile )
...
...
RETURN( NIL )
Samples how to use :
a) Accelerator defined inside the PRG
@ 25, 405 BTNBMP oBtnP[1] FILENAME c_path + "\System\Player1.bmp" ;
SIZE 40, 45 OF oDlg1 PIXEL NOBORDER ;
TOP ;
PROMPT cLang[5] + " &1" ;
FONT oTxtfont ;
ACTION ( nAktPlayer := 1, SET_PLAYER() )
oBtnP[1]:cTooltip := cLang[4] + " 1." + cLang[5]
oBtnP[1]:lTransparent := .T.
oBtnP[1]:l2007 := .F.
oBtnP[1]:SetColor( 128 )
b) Accelerator defined inside the INI
-- Keyword also used for Tooltipps
using a Keyword from INI with a defined Accelerator for Tooltipps, You can use SUBSTR(
@ 140, 455 BTNBMP oBtn[14] FILENAME c_path + "\System\Preview.bmp" ;
SIZE 40, 45 OF oDlg1 PIXEL NOBORDER ;
TOP ;
PROMPT cLang[10] ;
FONT oTxtfont ;
ACTION ( lVISIBLE := .T., ;
READ_GAME(), ;
oBrw1:SetArray( aImg ), oBrw1:Refresh() )
oBtn[14]:cTooltip := cLang[10] + " " + cLang[1]
oBtn[14]:lTransparent := .T.
oBtn[14]:l2007 := .F.
oBtn[14]:SetColor( 16312263 )
The Accelerator is defined inside the INI !!!
Show=&Show
Copy the English LANGUAGE.INI to a new German.ini
with defined Accelerators
[Language]
Game=&Spiel
Trials=&Versuche
Score=&Punkte
Select=&Auswahl
Player=Spie&ler
Training=T&raining
Reset=&zurücksetzen
...
...
Rename to LANGUAGE.INI
Best Regards
Uwe