下面是我的一个LANGUAGE.INI文件,用于菜单可用不同的语言显示(简体中文,繁体中文和英语)的一个例子.
[General]
FontName=宋体1
FontSize=12
Language=ChineseGB
[ChineseGB] //简体中文显示
MainForm_Caption=主界面
MainForm_Menu_N1=功能
MainForm_Menu_N4=导数
MainForm_Menu_N5=报表打印
MainForm_Menu_N12=数据分析
MainForm_Menu_N13=库存统计
MainForm_Menu_N6=退出
MainForm_Menu_N7=设置
MainForm_Menu_N8=简体中文
MainForm_Menu_N9=繁体中文
MainForm_Menu_N10=英文
//导数界面简体中文显示
ImportForm_Caption=导数
ImportForm_Label1=选择日期:
ImportForm_Label2=选择文件:
ImportForm_BitBtn1=确定
ImportForm_BitBtn2=取消
//报表打印界面简体中文显示
ReportPrintForm_Caption=报表打印
ReportPrintForm_Label1=日期:
ReportPrintForm_Label2=批次:
ReportPrintForm_GroupBox1=报表显示风格
ReportPrintForm_Rb1=标准
ReportPrintForm_Rb2=传统
ReportPrintForm_btPre=预览
ReportPrintForm_btPrint=打印
ReportPrintForm_btExit=退出
//数据分析
DataAnalysisFrom_Caption=数据分析
DataAnalysisFrom_label1=选择截止日期:
DataAnalysisFrom_label2=, 正在准备请稍候...
DataAnalysisFrom_GroupBox1=报表显示风格
DataAnalysisFrom_Rb1=标准
DataAnalysisFrom_Rb2=传统
DataAnalysisFrom_bt1=预览
DataAnalysisFrom_bt2=退出
//库存统计
StatisticStockFrom_Caption=库存统计
StatisticStockFrom_label=选择日期:
StatisticStockFrom_GroupBox1=报表显示风格
StatisticStockFrom_Rb1=标准
StatisticStockFrom_Rb2=传统
StatisticStockFrom_bt1=预览
StatisticStockFrom_bt2=退出
StatisticStockFrom_bt3=统计
//Compare TABLE STOCKLEDGER&STOCKLEDGER_4BU
CompareFrom_Caption=Compare STOCKLEDGER与4BU
CompareFrom_label1=选择公司
CompareFrom_label2=, 正在准备请稍候...
CompareFrom_GroupBox1=报表显示风格
CompareFrom_Rb1=标准
CompareFrom_Rb2=传统
CompareFrom_bt1=预览
CompareFrom_bt2=退出
[ChineseBig] //繁体中文显示
MainForm_Caption=???
MainForm_Menu_N1=??
MainForm_Menu_N4=旧计
MainForm_Menu_N5=厨?ゴ?
MainForm_Menu_N12=计沮だ猂
MainForm_Menu_N13=畐?参璸
MainForm_Menu_N6=癶?
MainForm_Menu_N7=砞竚
MainForm_Menu_N8=虏砰いゅ
MainForm_Menu_N9=羉砰いゅ
MainForm_Menu_N10=璣ゅ
//导数界面繁体中文显示
ImportForm_Caption=旧计
ImportForm_Label1=匡硂ら戳:
ImportForm_Label2=匡硂ゅン:
ImportForm_BitBtn1=絋﹚
ImportForm_BitBtn2=??
//报表打印界面繁体中文显示
ReportPrintForm_Caption=厨?ゴ?
ReportPrintForm_Label1=ら戳:
ReportPrintForm_Label2=уΩ:
ReportPrintForm_GroupBox1=厨?陪ボ??
ReportPrintForm_Rb1=夹?
ReportPrintForm_Rb2=肚参
ReportPrintForm_btPre=箇凝
ReportPrintForm_btPrint=ゴ?
ReportPrintForm_btExit=癶
//数据分析?
DataAnalysisFrom_Caption=计沮だ猂
DataAnalysisFrom_label1=匡拒篒ゎら戳:
DataAnalysisFrom_label2=, タ??称叫祔?...
DataAnalysisFrom_GroupBox1=厨?陪ボ??
DataAnalysisFrom_Rb1=夹?
DataAnalysisFrom_Rb2=肚参
DataAnalysisFrom_bt1=箇凝
DataAnalysisFrom_bt2=癶?
//库存统计
StatisticStockFrom_Caption=畐?参璸
StatisticStockFrom_label=匡拒ら戳:
StatisticStockFrom_GroupBox1=厨?陪ボ??
StatisticStockFrom_Rb1=夹?
StatisticStockFrom_Rb2=肚参
StatisticStockFrom_bt1=箇凝
StatisticStockFrom_bt2=癶?
StatisticStockFrom_bt3=参璸
//Compare TABLE STOCKLEDGER&STOCKLEDGER_4BU
CompareFrom_Caption=Compare STOCKLEDGER与4BU
CompareFrom_label1=匡拒そ?
CompareFrom_label2=, タ??称叫祔?...
CompareFrom_GroupBox1=厨?陪ボ??
CompareFrom_Rb1=夹?
CompareFrom_Rb2=肚参
CompareFrom_bt1=箇凝
CompareFrom_bt2=癶?
[ENGLISH] //英文显示
MainForm_Caption=MainForm
MainForm_Menu_N1=Functions
MainForm_Menu_N4=ImportData
MainForm_Menu_N5=ReportPrint
MainForm_Menu_N12=DataAnalysis
MainForm_Menu_N13=StatisticStock
MainForm_Menu_N6=Exit
MainForm_Menu_N7=Set
MainForm_Menu_N8=ChineseGB
MainForm_Menu_N9=ChineseBig
MainForm_Menu_N10=English
//导数界面英文显示
ImportForm_Caption=ImportData
ImportForm_Label1=SelectDate:
ImportForm_Label2=SelectFile:
ImportForm_BitBtn1=OK
ImportForm_BitBtn2=Cancel
//报表打印界面英文显示
ReportPrintForm_Caption=ReportPrint
ReportPrintForm_Label1=Date:
ReportPrintForm_Label2=Job:
ReportPrintForm_GroupBox1=ReportShowStyle
ReportPrintForm_Rb1=Standard
ReportPrintForm_Rb2=Custom
ReportPrintForm_btPre=Preview
ReportPrintForm_btPrint=Print
ReportPrintForm_btExit=Exit
//数据分析
DataAnalysisFrom_Caption=DataAnalysis
DataAnalysisFrom_label1=SelectCutOffDate:
DataAnalysisFrom_label2=, preparing,please wait...
DataAnalysisFrom_GroupBox1=ReportShowStyle
DataAnalysisFrom_Rb1=Standard
DataAnalysisFrom_Rb2=Custom
DataAnalysisFrom_bt1=Preview
DataAnalysisFrom_bt2=Exit
//库存统计
StatisticStockFrom_Caption=StatisticStock
StatisticStockFrom_label=SelectDate:
StatisticStockFrom_GroupBox1=ReportShowStyle
StatisticStockFrom_Rb1=Standard
StatisticStockFrom_Rb2=Custom
StatisticStockFrom_bt1=Preview
StatisticStockFrom_bt2=Exit
StatisticStockFrom_bt3=Stat.
//Compare TABLE STOCKLEDGER&STOCKLEDGER_4BU
CompareFrom_Caption=Compare STOCKLEDGER与4BU
CompareFrom_label1=Select CompID
CompareFrom_label2=, preparing,please wait...
CompareFrom_GroupBox1=ReportShowStyle
CompareFrom_Rb1=Standard
CompareFrom_Rb2=Custom
CompareFrom_bt1=Preview
CompareFrom_bt2=Exit
下面是在程序中怎么调用该文件,读取其中的内容.
procedure TfrmMain.ReadFromLanguageIni(SelectItem: integer);
var
IniFile: Tinifile;
Language: string;
begin
try
IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'Pro.ini');
Self.Font.Name := inifile.ReadString('General', 'FontName', '宋体');
Self.Font.Size := IniFile.ReadInteger('General', 'FontSize', 11);
case SelectItem of
0: Language := IniFile.ReadString('General', 'Language', 'ChineseGB'); //default
1: Language := 'ChineseGB';
2: Language := 'ChineseBig';
3: Language := 'ENGLISH';
end;
frmMain.Caption := IniFile.ReadString(Language, 'MainForm_Caption', frmMain.Caption);
N1.Caption := IniFile.ReadString(Language, 'MainForm_Menu_N1', N1.Caption);
N4.Caption := IniFile.ReadString(Language, 'MainForm_Menu_N4', N4.Caption);
N5.Caption := IniFile.ReadString(Language, 'MainForm_Menu_N5', N5.Caption);
N6.Caption := IniFile.ReadString(Language, 'MainForm_Menu_N6', N6.Caption);
N7.Caption := IniFile.ReadString(Language, 'MainForm_Menu_N7', N7.Caption);
N8.Caption := IniFile.ReadString(Language, 'MainForm_Menu_N8', N8.Caption);
N9.Caption := IniFile.ReadString(Language, 'MainForm_Menu_N9', N9.Caption);
N10.Caption := IniFile.ReadString(Language, 'MainForm_Menu_N10', N10.Caption);
N12.Caption := IniFile.ReadString(Language, 'MainForm_Menu_N12', N10.Caption);
N13.Caption := IniFile.ReadString(Language, 'MainForm_Menu_N13', N13.Caption);
with ImportDataRecord do
begin
FormCaption := IniFile.ReadString(Language, 'ImportForm_Caption', '');
Label1Caption := IniFile.ReadString(Language, 'ImportForm_Label1', '');
Label2Caption := IniFile.ReadString(Language, 'ImportForm_Label2', '');
BitBtn1Caption := IniFile.ReadString(Language, 'ImportForm_BitBtn1', '');
BitBtn2Caption := IniFile.ReadString(Language, 'ImportForm_BitBtn2', '');
end;
with ReportPrintRecord do
begin
FormCaption := IniFile.ReadString(Language, 'ReportPrintForm_Caption', '');
Label1Caption := IniFile.ReadString(Language, 'ReportPrintForm_Label1', '');
Label2Caption := IniFile.ReadString(Language, 'ReportPrintForm_Label2', '');
GroupBox1Caption := IniFile.ReadString(Language, 'ReportPrintForm_GroupBox1', '');
Rb1Caption := IniFile.ReadString(Language, 'ReportPrintForm_Rb1', '');
Rb2Caption := IniFile.ReadString(Language, 'ReportPrintForm_Rb2', '');
btPreCaption := IniFile.ReadString(Language, 'ReportPrintForm_btPre', '');
btPrintCaption := IniFile.ReadString(Language, 'ReportPrintForm_btPrint', '');
btExitCaption := IniFile.ReadString(Language, 'ReportPrintForm_btExit', '');
end;
with DataAnalysisRecord do
begin
FormCaption := IniFile.ReadString(Language, 'DataAnalysisFrom_Caption', '');
Label1Caption := IniFile.ReadString(Language, 'DataAnalysisFrom_label1', '');
Label2Caption := IniFile.ReadString(Language, 'DataAnalysisFrom_label2', '');
GroupBox1Caption := IniFile.ReadString(Language, 'DataAnalysisFrom_GroupBox1', '');
Rb1Caption := IniFile.ReadString(Language, 'DataAnalysisFrom_Rb1', '');
Rb2Caption := IniFile.ReadString(Language, 'DataAnalysisFrom_Rb2', '');
bt1Caption := IniFile.ReadString(Language, 'DataAnalysisFrom_bt1', '');
bt2Caption := IniFile.ReadString(Language, 'DataAnalysisFrom_bt2', '');
end;
with StatisticStockRecord do
begin
FromCaption := IniFile.ReadString(Language, 'StatisticStockFrom_Caption', '');
Label1Caption := IniFile.ReadString(Language, 'StatisticStockFrom_label', '');
GroupGox1Caption := IniFile.ReadString(Language, 'StatisticStockFrom_GroupBox1', '');
Rb1Caption := IniFile.ReadString(Language, 'StatisticStockFrom_Rb1', '');
Rb2Caption := IniFile.ReadString(Language, 'StatisticStockFrom_Rb2', '');
bt1Caption := IniFile.ReadString(Language, 'StatisticStockFrom_bt1', '');
bt2Caption := IniFile.ReadString(Language, 'StatisticStockFrom_bt2', '');
bt3Caption := IniFile.ReadString(Language, 'StatisticStockFrom_bt3', '');
end;
with CompareRecord do
begin
FormCaption := IniFile.ReadString(Language, 'CompareFrom_Caption', '');
Label1Caption := IniFile.ReadString(Language, 'CompareFrom_label1', '');
Label2Caption := IniFile.ReadString(Language, 'CompareFrom_label2', '');
GroupBox1Caption := IniFile.ReadString(Language, 'CompareFrom_GroupBox1', '');
Rb1Caption := IniFile.ReadString(Language, 'CompareFrom_Rb1', '');
Rb2Caption := IniFile.ReadString(Language, 'CompareFrom_Rb2', '');
bt1Caption := IniFile.ReadString(Language, 'CompareFrom_bt1', '');
bt2Caption := IniFile.ReadString(Language, 'CompareFrom_bt2', '');
end;
finally
IniFile.Free;
end;
end;
供参考