-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandTranslationUnit.cpp
More file actions
63 lines (52 loc) · 1.5 KB
/
CommandTranslationUnit.cpp
File metadata and controls
63 lines (52 loc) · 1.5 KB
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
61
62
63
/*
Open source not for commercial deployment
*/
//---------------------------------------------------------------------------
#pragma hdrstop
#include "CommandTranslationUnit.h"
//---------------------------------------------------------------------------
void CommandTranslation::AddTranslation(String s)
{
//replace translation
for (int i=0; i<MAX_TRANSLATION_COMMANDS; i++)
{
if (Command[i] == getUntil(s,"|"))
{
Translation[i] = getAfter(s,"|");
return;
}
}
//add translation
if (count == MAX_TRANSLATION_COMMANDS)
{
MessageDlg("Maximum number of translation commands reached.", mtInformation, TMsgDlgButtons()<<mbOK , 0);
return;
}
Command[count] = getUntil(s,"|");
Translation[count] = getAfter(s,"|");
count++;
}
CommandTranslation::CommandTranslation()
{
count = 0;
}
String CommandTranslation::translate(String s)
{
// new translation will be added so do not perform old translation
if (getUntil(s,"_")==("AddTranslation"))
return s;
for (int i= 0; i<count; i++)
{
int pos = s.Pos(Command[i]);
if (pos>0)
{
String retval = s.SubString(0,pos-1) +
Translation[i] +
s.SubString(pos + Command[i].Length(), s.Length() - pos + Command[i].Length());
retval = replace(retval, "|", ",");
return retval;
}
}
return s;
}
#pragma package(smart_init)