Skip to content

Commit

Permalink
Add test project (Delphi)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikitosiki committed Jun 4, 2023
1 parent 60e6e00 commit a44b1a4
Show file tree
Hide file tree
Showing 9 changed files with 711 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ProjectTestDelphi/Project1.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
program Project1;

uses
Vcl.Forms,
Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
458 changes: 458 additions & 0 deletions ProjectTestDelphi/Project1.dproj

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ProjectTestDelphi/Project1.dproj.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
<Transactions>
<Transaction>1899/12/30 00:00:00.000.154,C:\Users\Nikit\Documents\RAD Studio\Projects\Project1.dproj=C:\Users\Nikit\Documents\RAD Studio\Projects\Project1.dproj</Transaction>
<Transaction>1899/12/30 00:00:00.000.463,=C:\Users\Nikit\Documents\RAD Studio\Projects\Unit1.pas</Transaction>
</Transactions>
</BorlandProject>
Binary file added ProjectTestDelphi/Project1.identcache
Binary file not shown.
Binary file added ProjectTestDelphi/Project1.res
Binary file not shown.
4 changes: 4 additions & 0 deletions ProjectTestDelphi/Project2.dproj.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
<Transactions/>
</BorlandProject>
Binary file added ProjectTestDelphi/Project2.identcache
Binary file not shown.
109 changes: 109 additions & 0 deletions ProjectTestDelphi/Unit1.dfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 501
ClientWidth = 1026
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object Label3: TLabel
Left = 24
Top = 11
Width = 68
Height = 19
Caption = 'Language'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object Label1: TLabel
Left = 145
Top = 294
Width = 100
Height = 19
Caption = #1042#1086#1090' '#1090#1072#1082' '#1074#1086#1090'...'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object ComboBox1: TComboBox
Left = 98
Top = 8
Width = 169
Height = 27
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 0
Text = 'ComboBox1'
OnChange = ComboBox1Change
end
object Button1: TButton
Left = 624
Top = 151
Width = 241
Height = 129
Caption = 'Click Me'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 1
OnClick = Button1Click
end
object Panel1: TPanel
Left = 144
Top = 144
Width = 401
Height = 145
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 2
object Label5: TLabel
Left = 1
Top = 1
Width = 399
Height = 143
Align = alClient
Caption =
#1050#1086#1075#1076#1072'-'#1090#1086' '#1076#1072#1074#1085#1099#1084'-'#1076#1072#1074#1085#1086', '#1074' '#1089#1090#1088#1072#1085#1077' '#1064#1091#1090#1072#1085#1086#1074#1080#1080', '#1078#1080#1083' '#1086#1076#1080#1085' '#1085#1077#1074#1077#1088#1086#1103#1090#1085#1086' '#1089 +
#1084#1077#1096#1085#1086#1081' '#1095#1077#1083#1086#1074#1077#1082' '#1087#1086' '#1080#1084#1077#1085#1080' '#1041#1086#1073#1080#1082' '#1041#1072#1083#1072#1075#1072#1085#1086#1074'. '#1069#1090#1086#1090' '#1087#1072#1088#1077#1085#1100' '#1073#1099#1083' '#1085#1072#1089#1090#1086#1083#1100 +
#1082#1086' '#1096#1091#1090#1083#1080#1074#1099#1084', '#1095#1090#1086' '#1091' '#1085#1077#1075#1086' '#1076#1072#1078#1077' '#1085#1077' '#1073#1099#1083#1086' '#1086#1073#1099#1095#1085#1086#1081' '#1088#1072#1073#1086#1090#1099'. '#1042#1084#1077#1089#1090#1086' '#1101#1090#1086#1075 +
#1086', '#1086#1085' '#1079#1072#1088#1072#1073#1072#1090#1099#1074#1072#1083' '#1089#1077#1073#1077' '#1085#1072' '#1078#1080#1079#1085#1100', '#1087#1088#1086#1089#1090#1086' '#1079#1072#1089#1090#1072#1074#1083#1103#1103' '#1083#1102#1076#1077#1081' '#1089#1084#1077#1103#1090#1100#1089#1103 +
'.'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
WordWrap = True
ExplicitWidth = 386
ExplicitHeight = 114
end
end
end
119 changes: 119 additions & 0 deletions ProjectTestDelphi/Unit1.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
unit Unit1;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;

type
PAnsiCharArray = ^TAnsiCharArray;
TAnsiCharArray = array[0..0] of PAnsiChar;
TForm1 = class(TForm)
ComboBox1: TComboBox;
Label3: TLabel;
Button1: TButton;
Panel1: TPanel;
Label5: TLabel;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ComboBox1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

//function ReadXML(pathFile: PAnsiChar): Boolean; cdecl; external 'LocalizatorDll.dll' name 'ReadXML' delayed;
//function GetWordd(pathFile: PAnsiChar): PAnsiChar; cdecl; external 'LocalizatorDll.dll' name 'GetWord' delayed;
procedure Start(); cdecl; external 'LocalizatorDll.dll' name 'Start' delayed;
procedure Stop(); cdecl; external 'LocalizatorDll.dll' name 'Stop' delayed;
procedure SetSelectLanguage(nameLang: PAnsiChar); cdecl; external 'LocalizatorDll.dll' name 'SetSelectLanguage' delayed;
function GetWord(key: PAnsiChar): PAnsiChar; cdecl; external 'LocalizatorDll.dll' name 'GetWord' delayed;
function GetSelectLanguage(): PAnsiChar; cdecl; external 'LocalizatorDll.dll' name 'GetSelectLanguage' delayed;
function GetLanguageNames(var size: Integer): PAnsiCharArray; cdecl; external 'LocalizatorDll.dll' name 'GetLanguageNames' delayed;


// Ïðîöåäóðà ïåðåçàïóñêà ïðèëîæåíèÿ
procedure RestartApplication;
begin
WinExec(PAnsiChar(AnsiString(ParamStr(0))), SW_SHOW);
Application.Terminate;
end;


// Ïðîöåäóðà çàïîëíåíèÿ ôîðìû, îáðàæåíèå ê ñëîâàðþ
procedure FillTranslationForm();
begin
Form1.Label5.Caption := (GetWord('LDescriptoin'));
Form1.Label1.Caption := (GetWord('LDescriptoin2'));
Form1.Label3.Caption := Utf8ToAnsi(GetWord('LLanguageName'));
Form1.Button1.Caption := Utf8ToAnsi(GetWord('BClick'));
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
Label5.Caption := Utf8ToAnsi(GetWord('LDescriptoin3'));
end;


procedure TForm1.FormShow(Sender: TObject);
var
strings: PAnsiCharArray;
size: Integer;
i: Integer;
begin

// Ïðåäâàðèòåëüíàÿ çàãðóçêà
Start();

// Çàïîëíÿåì âûïàäàþùèé ñïèñîê ïåðå÷íÿ ÿçûêîâ
ComboBox1.Items.Clear;
strings := GetLanguageNames(size);
for i := 0 to size - 1 do
ComboBox1.Items.Add(Utf8ToAnsi(strings[i]));

// Îòîáðàæàåì âûáðàííûé ÿçûê
ComboBox1.Text := Utf8ToAnsi(GetSelectLanguage());

// Íà÷èíàåì ïåðåâîäèòü (çàïîëíÿòü) ôîðìó
FillTranslationForm();

end;


procedure TForm1.ComboBox1Change(Sender: TObject);
var
reboot: Integer;
begin

// Èçìåíÿåì ÿçèê ñèñòåìû
SetSelectLanguage(PAnsiChar(AnsiToUtf8(ComboBox1.Text)));

reboot := MessageDlg('Ïåðåçàãðóçèòü ïðîãðàììó, ÷òîáû ïðèìåíèòü èçìåíåíèÿ?', mtConfirmation, [mbYes, mbNo], 0);
if reboot = mrYes then
RestartApplication;


end;


procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin

// Âûçûâàåì êîððåêòíîå çàâåðøåíèå ëîêàëèçàòîðà
Stop();

end;

end.

0 comments on commit a44b1a4

Please sign in to comment.