summaryrefslogtreecommitdiff
path: root/tools/replacer/unit1.pas
blob: b6a66bed0cb984dee74142b436325f99321100d0 (plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
unit Unit1;



interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  CheckLst;
{  IMAGE_FILE_LINE_NUMS_STRIPPED or IMAGE_FILE_LOCAL_SYMS_STRIPPED
  $WEAKLINKRTTI ON $RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([]) }
type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    CheckListBox1: TCheckListBox;
    Edit1: TEdit;
    Edit2: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);

  private
    { private declarations }
  public
    { public declarations }
  end;

var

   Form1: TForm1;
  d:tsearchrec;
  a:TStringList;
  langs:TStringList;
  i,j:integer;
  s:string;
  r,t:integer;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
    CheckListBox1.Items.clear;
    langs:=TstringList.Create;
    r:=findfirst(extractfilePath(application.exename)+'*',faanyfile,d);
    while r = 0 do
      begin
        if ((d.attr and fadirectory)=fadirectory)
        and ((d.name='.')or(d.name='..')) then
          begin r:=findnext(d); continue; end;
        if ((d.attr and fadirectory)=fadirectory)
        and (fileexists(extractfilepath(application.exename)+
        '/'+d.name+'/=HEAD=.txt')) then
      begin
       langs.Add(d.name);
      end;
        r:=FindNext(d);
      end;
FindClose(d);


for i := 0 to langs.Count-1 do
begin
  a:=TstringList.Create;
  if fileexists(extractfilepath(application.exename)+langs[i]+'/'+'=CORE=.txt') then
    begin
      a.LoadFromFile(extractfilepath(application.exename)+langs[i]+'/'+'=CORE=.txt');
      for j := 0 to a.count-1 do
      if a[j]=edit1.text then
        begin
          CheckListBox1.Items.Add(langs[i]+'/'+'=CORE=.txt');
          break;
        end;

     end;
 a.Free;

 r:=FindFirst(ExtractFilePath(Application.ExeName)+'/'
+langs[i]+'/plugins/*.txt', faAnyFile, d);
 while r = 0 do
    begin
      a:=TstringList.Create;
      a.LoadFromFile(extractfilepath(application.exename)
      +'/'+langs[i]+'/'+'plugins/'+d.name);
      for j := 0 to a.count-1 do
        if a[j]=edit1.text then
          begin
            CheckListBox1.Items.Add(langs[i]+'/'+'plugins/'+d.name);
            break;
          end;
      a.free;
       r:=FindNext(d);
    end;
     FindClose(d);

r:=FindFirst(ExtractFilePath(Application.ExeName)+'/'
+langs[i]+'/weather/*.txt', faAnyFile, d);
 while r = 0 do
    begin
      a:=TstringList.Create;
      a.LoadFromFile(extractfilepath(application.exename)
      +'/'+langs[i]+'/'+'weather/'+d.name);
      for j := 0 to a.count-1 do
        if a[j]=edit1.text then
          begin
            CheckListBox1.Items.Add(langs[i]+'/'+'plugins/'+d.name);
            break;
          end;
      a.free;
       r:=FindNext(d);
    end;
     FindClose(d);

end;

for i := 0 to CheckListBox1.Count-1 do
 CheckListBox1.Checked[i]:=true;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 for i := 0 to CheckListBox1.Count-1 do
 if CheckListBox1.Checked[i]=true then
 begin
    a:=TstringList.Create;
    a.LoadFromFile(extractfilepath(application.exename)
      +'/'+CheckListBox1.Items[i]);
    for j := 1 to a.Count-1 do
      if a[j]=edit1.text then  a[j]:=edit2.text;
    a.SaveToFile(extractfilepath(application.exename)
      +'/'+CheckListBox1.Items[i]);
 end;
end;

end.