如何象flashget那样利用ini文件实现多国语言程序。(100分)

  • 主题发起人 主题发起人 mumu
  • 开始时间 开始时间
M

mumu

Unregistered / Unconfirmed
GUEST, unregistred user!
最好有具体的demo。borland.delphi.demo中的多国语言不方便:(
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants,inifiles, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
RBEnglish: TRadioButton;
RBTw: TRadioButton;
ComboBox1: TComboBox;
Button1: TButton;
Label1: TLabel;
procedure RBEnglishClick(Sender: TObject);
procedure RBTwClick(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Myini:TiniFile;
implementation

{$R *.dfm}

procedure TForm1.RBEnglishClick(Sender: TObject);
var
name:String;
begin
name:=ExtractFilePath(Paramstr(0))+'english.ini';
Myini:=TiniFile.Create(name);
GroupBox1.Caption:=Myini.ReadString('language','GroupBox1','');
RBEnglish.Caption:=Myini.ReadString('language','RBEnglish','');
RBTw.Caption:=Myini.ReadString('language','RBTw','');
Button1.Caption:=Myini.ReadString('language','Button1','');
Label1.Caption:=Myini.ReadString('language','Label1','');
GroupBox1.Hint:=Myini.ReadString('language','GroupBox1','');
RBEnglish.Hint:=Myini.ReadString('language','RBEnglish','');
RBTw.Hint:=Myini.ReadString('language','RBTw','');
Button1.Hint:=Myini.ReadString('language','Button1','');
Label1.Hint:=Myini.ReadString('language','Label1','');
ComboBox1.Text:='English';
end;

procedure TForm1.RBTwClick(Sender: TObject);
var
name:String;
begin
name:=ExtractFilePath(Paramstr(0))+'TaiWan.ini';
Myini:=TiniFile.Create(name);
GroupBox1.Caption:=Myini.ReadString('language','GroupBox1','');
RBEnglish.Caption:=Myini.ReadString('language','RBEnglish','');
RBTw.Caption:=Myini.ReadString('language','RBTw','');
Button1.Caption:=Myini.ReadString('language','Button1','');
Label1.Caption:=Myini.ReadString('language','Label1','');
GroupBox1.Hint:=Myini.ReadString('language','GroupBox1','');
RBEnglish.Hint:=Myini.ReadString('language','RBEnglish','');
RBTw.Hint:=Myini.ReadString('language','RBTw','');
Button1.Hint:=Myini.ReadString('language','Button1','');
Label1.Hint:=Myini.ReadString('language','Label1','');
ComboBox1.Text:='TaiWan';
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
var
name:String;
begin
if ComboBox1.Text='English' then
begin
name:=ExtractFilePath(Paramstr(0))+'english.ini';
Myini:=TiniFile.Create(name);
GroupBox1.Caption:=Myini.ReadString('language','GroupBox1','');
RBEnglish.Caption:=Myini.ReadString('language','RBEnglish','');
RBTw.Caption:=Myini.ReadString('language','RBTw','');
Button1.Caption:=Myini.ReadString('language','Button1','');
Label1.Caption:=Myini.ReadString('language','Label1','');
GroupBox1.Hint:=Myini.ReadString('language','GroupBox1','');
RBEnglish.Hint:=Myini.ReadString('language','RBEnglish','');
RBTw.Hint:=Myini.ReadString('language','RBTw','');
Button1.Hint:=Myini.ReadString('language','Button1','');
Label1.Hint:=Myini.ReadString('language','Label1','');
end
else
begin
name:=ExtractFilePath(Paramstr(0))+'TaiWan.ini';
Myini:=TiniFile.Create(name);
GroupBox1.Caption:=Myini.ReadString('language','GroupBox1','');
RBEnglish.Caption:=Myini.ReadString('language','RBEnglish','');
RBTw.Caption:=Myini.ReadString('language','RBTw','');
Button1.Caption:=Myini.ReadString('language','Button1','');
Label1.Caption:=Myini.ReadString('language','Label1','');
GroupBox1.Hint:=Myini.ReadString('language','GroupBox1','');
RBEnglish.Hint:=Myini.ReadString('language','RBEnglish','');
RBTw.Hint:=Myini.ReadString('language','RBTw','');
Button1.Hint:=Myini.ReadString('language','Button1','');
Label1.Hint:=Myini.ReadString('language','Label1','');
end;
end;

end.
 

Similar threads

回复
0
查看
978
不得闲
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部