More and more programs use a multi-language switch, although the Delphi with the addition and configuration of multiple language packages, but that way in the switch language interface will appear flashing, and to achieve a very troublesome, here I introduce you to the use of INI file to read the interface of the language text, with this method, not only simple, And there is no flicker of the interface when switching.
Let's start with an example to see how to implement a language switch. First, a new project is established. Place the following components:
MainMenu1: TMainMenu;
File1: TMenuItem;
Exit1: TMenuItem;
Label1: TLabel;
Button1: TButton;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
Button2: TButton;
Label2: TLabel;
ComboBox1: TComboBox;
Label3: TLabel;
Because you want to read the INI file, add the declaration inifiles to the uses, and then set the Showhint property of Button1 and Button2 to True, where we use ComboBox1 to display the language that is available and to select the language.
We edit the following Chinese GB in the directory of the program. INI file:
;
;
; 翻译的一些规则:
; 翻译前,拷贝 Chinese GB.ini 改名到 yourlanguage.ini
; 仅仅翻译符号'='后的文字
;
[Translations]
;
Label1.Caption =文字1
Label2.Caption =文字2
Label3.Caption =语言
Button1.Caption =按钮1
Button2.Caption =按钮2
Button1.Hint =按钮1_提示
Button2.Hint =按钮2_提示
CheckBox1.Caption =复选框1
CheckBox2.Caption =复选框2
File1.Caption =文件
Exit1.Caption =退出
;
[Messages]
;
M1 =信息框测试
;
;