-
Notifications
You must be signed in to change notification settings - Fork 2
/
MLTS.cpp
60 lines (45 loc) · 1.09 KB
/
MLTS.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//---------------------------------------------------------------------------
#include <map>
#include <vcl.h>
#include <IniFiles.hpp>
#pragma hdrstop
#include "MLTS.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
std::map<String,String> mltsmap;
void InitMLTS(String filename)
{
mltsmap.clear();
TIniFile *ini = new TIniFile(filename);
TStringList *strs = new TStringList;
ini->ReadSection("lang",strs);
for(int i=0;i<strs->Count;i++)
{
String key = strs->Strings[i];
String value = ini->ReadString("lang",key,key);
mltsmap[key] = value;
}
delete strs;
delete ini;
// mltsmap["Save"] = "ÀúÀå";
// mltsmap["Load"] = "Àбâ";
}
String MLTS(const String &s)
{
if(mltsmap.find(s)==mltsmap.end()) return s;
return mltsmap[s];
}
void ApplyMLTS(TForm *form)
{
PPropInfo propinfo;
for(int i=0;i<form->ComponentCount;i++)
{
TComponent *comp = form->Components[i];
propinfo = GetPropInfo(comp,"Caption");
if(propinfo)
{
String s = GetStrProp(comp,"Caption");
SetStrProp(comp,"Caption",MLTS(s));
}
}
}