/*@file mlanguage.cpp
*compiled ok with vc++6.0
功能:基于ini文件的多国语言配置演示模型
language.ini默认位置为e:/language.ini
language.ini文件内容如下:
[english]
name =multi language demo
fun =***function***
add =1.insert
del =2.delete
mdf =3.modify
sav =4.save
[Simplified]
name =多国语言演示版本
fun =***主要功能***
add =1.插入
del =2.删除
mdf =3.修改
sav =4.保存
[Traditional]
name =多國語言演示版本
fun =***主要功能***
add =1.插入
del =2.刪除
mdf =3.修改
sav =4.保存
*/
#include <iostream>
#include "windows.h"
using namespace std;
#define English 1
#define Simplified 2
#define Traditional 3
char filename[30]="E://language.ini";
char name[80],function[30];
char m1[30],m2[30],m3[30],m4[30];
int choose_language();//选择语言
void conver_language(int);//转换语言
void print_language();//显示操作界面
void get_English();//读取英文字符
void get_Simplified();//读取简体字符
void get_Traditional();//读取繁体字符
void main()
{
conver_language(choose_language());
print_language();
}
int choose_language(){
int choice=0;
cout<<"1.English,2.Simplified,3.Traditional /n";
cout<<"choose language [1-3]/n";
cin>>choice;
return choice;
}
//语言转换函数
void conver_language(int choose){
switch(choose) {
case English:
get_English();
break;
case Simplified:
get_Simplified();
break;
case Traditional:
get_Traditional();
break;
}
}
//显示操作界面
void print_language(){
system("cls");
cout<<"/n";
cout<<name<<endl;
cout<<function<<endl;
cout<<m1<<endl;
cout<<m2<<endl;
cout<<m3<<endl;
cout<<m4<<endl;
cout<<"/n/n";
}
//english
void get_English()
{
GetPrivateProfileString("english","name","",name,sizeof(name),filename);
GetPrivateProfileString("english","fun","",function,sizeof(function),filename);
GetPrivateProfileString("english","add","",m1,sizeof(m1),filename);
GetPrivateProfileString("english","del","",m2,sizeof(m2),filename);
GetPrivateProfileString("english","mdf","",m3,sizeof(m3),filename);
GetPrivateProfileString("english","sav","",m4,sizeof(m4),filename);
}
//简体中文
void get_Simplified()
{
GetPrivateProfileString("Simplified","name","",name,sizeof(name),filename);
GetPrivateProfileString("Simplified","fun","",function,sizeof(function),filename);
GetPrivateProfileString("Simplified","add","",m1,sizeof(m1),filename);
GetPrivateProfileString("Simplified","del","",m2,sizeof(m2),filename);
GetPrivateProfileString("Simplified","mdf","",m3,sizeof(m3),filename);
GetPrivateProfileString("Simplified","sav","",m4,sizeof(m4),filename);
}
//繁体中文
void get_Traditional()
{
GetPrivateProfileString("Traditional","name","",name,sizeof(name),filename);
GetPrivateProfileString("Traditional","fun","",function,sizeof(function),filename);
GetPrivateProfileString("Traditional","add","",m1,sizeof(m1),filename);
GetPrivateProfileString("Traditional","del","",m2,sizeof(m2),filename);
GetPrivateProfileString("Traditional","mdf","",m3,sizeof(m3),filename);
GetPrivateProfileString("Traditional","sav","",m4,sizeof(m4),filename);
}