//设置组件Caption
if PropertyExists(AComponent,SCaption) then
begin
s := ReadString(SIniLanguage,AComponent.Name+''.''+SCaption,'''');
if s<>'''' then
SetStringPropertyIfExists(AComponent,SCaption,s);
end;
//读取字体
if PropertyExists(AComponent,''Font'') then
begin
s := ReadString(SIniLanguage,''FontName'','''');
i := ReadInteger(SIniLanguage,''FontSize'',0);
if s<>'''' then
SetStringPropertyIfExists(
GetObjectProperty(AComponent,''Font''),''Name'',s);
if i > 0 then
SetIntegerPropertyIfExists(
GetObjectProperty(AComponent,''Font''),''Size'',i);
end;
//列举所有子组件并设置属性
for i := 0 to AComponent.ComponentCount - 1 do
begin
//设置Caption
if PropertyExists(AComponent.Components[i],SCaption) then
begin
s := ReadString(SIniLanguage,AComponent.Name+''.''+
AComponent.Components[i].Name+''.''+SCaption,'''');
if s<>'''' then
SetStringPropertyIfExists(AComponent.Components[i],SCaption,s);
end;
//设置Hint
if PropertyExists(AComponent.Components[i],SHint) then
begin
s := ReadString(SIniLanguage,AComponent.Name+''.''+
AComponent.Components[i].Name+''.''+SHint,'''');
if s = '''' then //如果Hint为空,则改Hint同Caption
s := GetStringProperty(AComponent.Components[i],SCaption);
if s<>'''' then
SetStringPropertyIfExists(AComponent.Components[i],SHint,s);
end;
end;
//更改默认语言文件为当前文件
FsLanguage := sFileName;
finally
Free;
end;
end;
//示例INI文件Chinese.ini
[Language]
LanguageName=中文
AppName=窗口查看器
Menu=菜单
Null=(空)
About=关于(&A)
Warning=警告
Confirm=确认
Error=错误
Information=信息
FontName=宋体
FontSize=9
FrmWindowView.Caption=窗口查看器
FrmWindowView.tbFile.Caption=文件(&F)
FrmWindowView.tbFile.Hint=文件菜单
FrmWindowView.tbOption.Caption=选项(&O)
FrmWindowView.tbOption.Hint=选项菜单
FrmWindowView.tbTools.Caption=工具(&T)
FrmWindowView.tbTools.Hint=工具菜单
FrmWindowView.tbHelp.Caption=帮助(&H)
FrmWindowView.tbHelp.Hint=帮助菜单
FrmWindowView.panSearch.Caption=搜索文本:
FrmWindowView.panSearch.Hint=搜索文本
FrmWindowView.edtSearch.Hint=在此键入搜索文本
FrmWindowView.btnSearch.Caption=搜索
FrmWindowView.btnSearch.Hint=开始搜索
FrmWindowView.tv.Hint=捕获结果,按鼠标右键弹出动作菜单
FrmWindowView.acExit.Caption=退出(&X)
FrmWindowView.acExit.Hint=退出程序
FrmWindowView.acLockCapture.Caption=锁定捕获
FrmWindowView.acLockCapture.Hint=选定后将鼠标移动到目标对象上
FrmWindowView.acCapture.Caption=捕获
FrmWindowView.acCapture.Hint=按住鼠标然后拖曳到目标对象上
FrmWindowView.acCaptureAll.Caption=捕获所有
FrmWindowView.acCaptureAll.Hint=捕获所有可列举出的窗口
FrmWindowView.acAutoHide.Caption=自动隐藏
FrmWindowView.acAutoHide.Hint=在捕获时自动隐藏程序
FrmWindowView.acStayOnTop.Caption=总在最前
FrmWindowView.acStayOnTop.Caption=窗口总在最前
FrmWindowView.acLanguage.Caption=语言(&L)
FrmWindowView.acLanguage.Hint=选择语