it is not easy to install language support in our program. The text assignment for every object looks like this
Code: Select all
CheckBox4_Caption := 'Background';
and this lines are spread over the source code. With some little changes, it get easy to create language support.
first define const strings in the same area
Code: Select all
const
cL0_CheckBox2_Caption = 'Color';
cL0_CheckBox4_Caption = 'Background';
.
.
.
Code: Select all
procedure SetLanguage0()
strncpy(CheckBox2_Caption, cL0_CheckBox2_Caption, SizeOf(CheckBox2_Caption));
strncpy(CheckBox4_Caption, cL0_CheckBox4_Caption, SizeOf(cL0_CheckBox4_Caption));
.
.
.
Code: Select all
procedure InitObjects();
begin
.
.
.
SetLanguage0();
end;
Code: Select all
const
cL1_CheckBox2_Caption = 'Farbe';
cL1_CheckBox4_Caption = 'Hintergrund';
.
.
.
Code: Select all
procedure SetLanguage1()
strncpy(CheckBox2_Caption, cL1_CheckBox2_Caption, SizeOf(CheckBox2_Caption));
strncpy(CheckBox4_Caption, cL1_CheckBox4_Caption, SizeOf(CheckBox4_Caption));
.
.
.
and with a more robust function
Code: Select all
const
MaxLanguageNo = 2;
var
LanguageNo: byte;
procedure SetLanguage(ALanguageNo: byte);
begin
if ALanguageNo<0 then begin
ALanguageNo:=0;
end;
if ALanguageNo>=MaxLanguageNo then begin
ALanguageNo:=MaxLanguageNo-1;
end;
if LanguageNo<>ALanguageNo then begin
LanguageNo:=ALanguageNo;
case LanguageNo of
0: SetLanguage0();
1: SetLanguage1();
.
.
.
end;
end;
end;
Code: Select all
procedure EveButton1OnClick();
begin
SetLanguage(LanguageNo-1);
DrawScreen(@Screen1);
end;
procedure EveButton2OnClick();
begin
SetLanguage(LanguageNo+1);
DrawScreen(@Screen1);
end;
So, in Visual TFT there must be only rearrange some "generate code" lines and a MaxLanguageNo to generate the language string tables and the SetLanguageX function. A Member in the IDE like "Max Length" with the name "LanguageSupport YES/NO" can filter the text witch are not to translate.
Best regards
Thomas