diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-06-25 16:26:07 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-06-25 16:26:07 +0000 |
commit | a37e2d8a1144d31f44977e4ccdb036d06ed0254d (patch) | |
tree | b22b1f6aa6ee368ead0c40784ec4188d76a952aa /tools/langpackmgr | |
parent | a5d58f74315af7451155d7976311ecd30627445f (diff) |
- langpackmgr tool source code update (by Jebifor)
git-svn-id: http://svn.miranda-ng.org/main/trunk@5130 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'tools/langpackmgr')
-rw-r--r-- | tools/langpackmgr/Unit1.pas | 358 |
1 files changed, 175 insertions, 183 deletions
diff --git a/tools/langpackmgr/Unit1.pas b/tools/langpackmgr/Unit1.pas index 59c76c06b0..2ddb8f0be7 100644 --- a/tools/langpackmgr/Unit1.pas +++ b/tools/langpackmgr/Unit1.pas @@ -9,28 +9,28 @@ uses type
TForm1 = class(TForm)
Label1: TLabel;
- ListBox1: TListBox;
- OpenDialog1: TOpenDialog;
+ Label2: TLabel;
+ Label3: TLabel;
Edit1: TEdit;
+ Edit2: TEdit;
+ Edit3: TEdit;
Button1: TButton;
Button2: TButton;
+ Button3: TButton;
+ ListBox1: TListBox;
+ OpenDialog1: TOpenDialog;
C: TBitBtn;
X: TBitBtn;
- Label2: TLabel;
- Edit2: TEdit;
- Edit3: TEdit;
- Label3: TLabel;
- Button3: TButton;
- procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
+ procedure Button1Click(Sender: TObject);
+ procedure Button2Click(Sender: TObject);
+ procedure Button3Click(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
+ procedure CClick(Sender: TObject);
+ procedure XClick(Sender: TObject);
procedure refresh;
procedure read;
procedure enter(Sender: TObject; var Key: Word; Shift: TShiftState);
- procedure CClick(Sender: TObject);
- procedure XClick(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
private
{ Private declarations }
@@ -41,27 +41,156 @@ type var
Form1: TForm1;
openDialog : TOpenDialog;
- full: array [1..7000] of string;
+ full,ustring,tstring,fline,dupes: array [1..7000] of string;
notranslate: array [1..7000] of integer;
- ustring,tstring: array [1..7000] of string;
- fline:array [1..2,1..7000] of string;
- english,translate: textfile;
- line:string;
+ translate: textfile;
+ bom, bomd, line:string;
ii,i,it,ie:integer;
- bom, bomd:string;
- dupes: array [1..7000] of string;
idx,idm:integer;
cores:boolean;
implementation
{$R *.dfm}
-procedure tform1.read;
+// Открытие файла
+procedure TForm1.Button1Click(Sender: TObject);
+ begin
+ chdir(ExtractFilePath(Application.ExeName));
+ chdir('..');
+ openDialog := TOpenDialog.Create(self);
+ openDialog.Filter := 'Text files only|*.txt';
+ openDialog.InitialDir :=GetCurrentDir ;
+ openDialog.Options := [ofFileMustExist];
+ if (openDialog.Execute)
+ and(extractfilename(openDialog.filename)<>'=HEAD=.txt')
+ and(extractfilename(openDialog.filename)<>'=DUPES=.txt')
+then
+ begin
+ edit1.Text:=copy(openDialog.filename,
+ length(ExtractFilePath(Application.ExeName))-4,
+ length(openDialog.filename)-length(ExtractFilePath(Application.ExeName))+5);
+ read;
+ refresh;
+ end;
+end;
+
+// Процедура сохранения обработанного файла
+procedure TForm1.Button2Click(Sender: TObject);
+begin
+refresh;
+assignfile(translate,opendialog.filename,CP_UTF8);
+rewrite(translate);
+writeLn(translate, bom);
+ for i := 1 to ie do
+ begin
+ if copy(ustring[i],1,1)=';' then writeln(translate,ustring[i]);
+ if (copy(ustring[i],1,1)='[') and (tstring[i]<>'')
+ then begin
+ cores:=false;
+ if Button3.caption='DUPES ON' then
+ for idx := 1 to idm do
+ if (copy(dupes[idx],1,1)='[')
+ and (dupes[idx]=ustring[i])
+ then cores:=true;
+ if cores=false then
+ begin
+ writeln(translate,ustring[i]);
+ writeln(translate,tstring[i]);
+ end;
+ end;
+ end;
+closefile(translate);
+
+// Процедура пересохранения файла =DUPES=
+ if (extractfilename(openDialog.filename)='=CORE=.txt')
+ and (FileExists(ExtractFilePath(opendialog.filename)+'=DUPES=.txt')=true)
+ then
+ begin
+assignfile(translate,ExtractFilePath(opendialog.filename)+'=DUPES=.txt',CP_UTF8);
+rewrite(translate);
+writeLn(translate, bomd);
+//
+// Если строка отсутствует в =СORE=, она запишется в =DUPES=
+for idx := 1 to idm do
+if (copy(dupes[idx],1,1)='[') then
+ begin cores:=false;
+ for i := 1 to ie do
+ if dupes[idx]=ustring[i] then cores:=true;
+ if cores=true then begin
+ writeLn(translate, dupes[idx]);
+ writeLn(translate, dupes[idx+1]);
+ end;
+ end;
+closefile(translate);
+ end;
+//
+ read;
+end;
+
+// Выключение фильтра повторяющихся строк
+procedure TForm1.Button3Click(Sender: TObject);
begin
+if edit1.Text<>'' then
+If Button3.Caption='DUPES OFF'
+then Button3.Caption:='DUPES ON'
+else Button3.Caption:='DUPES OFF';
+refresh;read;refresh;
+end;
+procedure TForm1.CClick(Sender: TObject);
+begin
+ Edit3.text:=edit2.text;
+end;
+
+procedure TForm1.XClick(Sender: TObject);
+begin
+ Edit3.text:='';
+ tstring[notranslate[strtoint(label2.caption)]]:='';
+ refresh;
+end;
+
+procedure TForm1.enter(Sender: TObject; var Key: Word;
+ Shift: TShiftState);
+begin
+case key of
+ vk_return,vk_down: if listbox1.ItemIndex<listbox1.Items.Count then
+ listbox1.ItemIndex:=listbox1.ItemIndex+1;
+ vk_up: if listbox1.ItemIndex>0 then
+ listbox1.ItemIndex:=listbox1.ItemIndex-1;
+end;
+refresh;
+end;
+
+procedure TForm1.ListBox1Click(Sender: TObject);
+begin
+ refresh;
+end;
+
+procedure TForm1.FormCreate(Sender: TObject);
+begin
+ KeyPreview := True;
+end;
+
+procedure tform1.refresh;
+var n:integer;
+begin
+n:=strtoint(label2.caption);
+line:=edit3.Text;
+if length(line)<>0 then
+tstring[notranslate[n]]:=line;
+label2.Caption:=inttostr(ListBox1.ItemIndex+1);
+n:=strtoint(label2.caption);
+edit2.Text:=copy(ustring[notranslate[n]],2,length(ustring[notranslate[n]])-2);
+edit2.SelectAll;
+edit2.CopyToClipboard;
+edit3.Text:=tstring[notranslate[n]];
+edit3.SetFocus;
+end;
+
+procedure tform1.read;
+begin
if extractfilename(opendialog.filename)='=CORE=.txt'
then button3.Visible:=false
else button3.Visible:=true;
-
listbox1.Items.Clear;
line:='';
edit3.Text:='';
@@ -69,11 +198,11 @@ else button3.Visible:=true; begin
full[i]:='';
dupes[i]:='';
- notranslate[i]:=0;
- ustring[i]:='';
- tstring[i]:='';
+ notranslate[i]:=0;
+ ustring[i]:='';
+ tstring[i]:='';
end;
-
+// Считывание выбранного файла в full[it]
assignfile(translate,opendialog.filename,CP_UTF8);
reset(translate);
it:=0;
@@ -85,15 +214,19 @@ else button3.Visible:=true; it:=it+1;
full[it]:=line;
ReadLn(translate, line);
- if (copy(line,1,1)<>'')and(copy(line,1,1)<>';')and(copy(line,1,1)<>'[')then
- begin
- it:=it+1;
- full[it]:=line;
- end else it:=it-1;
+ if (copy(line,1,1)<>'')
+ and(copy(line,1,1)<>';')
+ and(copy(line,1,1)<>'[')
+ then begin
+ it:=it+1;
+ full[it]:=line;
+ end
+ else it:=it-1;
end;
end;
closefile(translate);
+// Считывание файла повторяющихся строк в dupes[idm]
idm:=0;
if FileExists(ExtractFilePath(opendialog.filename)+'=DUPES=.txt')=true then
begin
@@ -115,7 +248,7 @@ reset(translate); end;
closefile(translate);
end;
-
+// то же, если =DUPES= находится на директорию выше
if FileExists(ExtractFilePath(opendialog.filename)+'\..\=DUPES=.txt')=true then
begin
assignfile(translate,ExtractFilePath(opendialog.filename)+'\..\=DUPES=.txt',CP_UTF8);
@@ -135,14 +268,14 @@ reset(translate); end;
closefile(translate);
end;
-
if extractfilename(opendialog.filename)='=CORE=.txt' then
begin
-assignfile(english,ExtractFilePath(Application.ExeName)+
+assignfile(translate,ExtractFilePath(Application.ExeName)+
'\..\english\'+extractfilename(opendialog.filename),CP_UTF8);
end
else
begin
+// если обрабатываемый файл - не =CORE=, повторяющиеся строки считываются и из него.
assignfile(translate,ExtractFilePath(opendialog.filename)+'\..\=CORE=.txt',CP_UTF8);
reset(translate);
while not Eof(translate) do
@@ -161,180 +294,39 @@ reset(translate); end;
end;
closefile(translate);
-
-assignfile(english,ExtractFilePath(Application.ExeName)+
+assignfile(translate,ExtractFilePath(Application.ExeName)+
'\..\english\plugins\'+extractfilename(opendialog.filename),CP_UTF8);
end;
- reset(english);
- ReadLn(english, bom);
+ reset(translate);
+ ReadLn(translate, bom);
ie:=0;
-while not Eof(english) do
+while not Eof(translate) do
begin
- ReadLn(english, line);
+ ReadLn(translate, line);
ie:=ie+1;
ustring[ie]:=line;
end;
- closefile(english);
-
+ closefile(translate);
for i := 1 to ie do
-begin
for ii:= 1 to it-1 do
-if ustring[i]=full[ii] then tstring[i]:=full[ii+1];
-if copy(ustring[i],1,1)=';' then tstring[i]:=ustring[i];
-end;
+ if ustring[i]=full[ii]
+ then tstring[i]:=full[ii+1];
for i := 1 to ie do
-if tstring[i]='' then
+if (copy(ustring[i],1,1)='[') and (tstring[i]='') then
begin
-
if (extractfilename(opendialog.filename)='=CORE=.txt') and (idm>0) then
for idx := 1 to idm do
if dupes[idx]=ustring[i] then tstring[i]:=dupes[idx+1];
-
if (extractfilename(opendialog.filename)<>'=CORE=.txt') and (idm>0)
and (button3.Caption='DUPES ON') then
for idx := 1 to idm do
if dupes[idx]=ustring[i] then tstring[i]:=dupes[idx+1];
-
if tstring[i]='' then
begin
listbox1.Items.Add(ustring[i]);
notranslate[listbox1.Items.Count]:=i;
end;
end;
-
label3.caption:='Untranslate:'+inttostr(listbox1.Items.Count)+' lines.';
end;
-
-
-procedure tform1.refresh;
-var n:integer;
-begin
-n:=strtoint(label2.caption);
-line:=edit3.Text;
-if length(line)<>0 then
-tstring[notranslate[n]]:=line;
-label2.Caption:=inttostr(ListBox1.ItemIndex+1);
-n:=strtoint(label2.caption);
-edit2.Text:=copy(ustring[notranslate[n]],2,length(ustring[notranslate[n]])-2);
-edit2.SelectAll;
-edit2.CopyToClipboard;
-edit3.Text:=tstring[notranslate[n]];
-edit3.SetFocus;
-end;
-
-
-
-procedure TForm1.Button1Click(Sender: TObject);
- begin
- chdir(ExtractFilePath(Application.ExeName));
- chdir('..');
- openDialog := TOpenDialog.Create(self);
- openDialog.Filter := 'Text files only|*.txt';
- openDialog.InitialDir :=GetCurrentDir ;
- openDialog.Options := [ofFileMustExist];
- if (openDialog.Execute)
- and(extractfilename(openDialog.filename)<>'=HEAD=.txt')
- and(extractfilename(openDialog.filename)<>'=DUPES=.txt')
- and(extractfilename(openDialog.filename)<>'untranslated.txt')
-then
- begin
- edit1.Text:=copy(openDialog.filename,
- length(ExtractFilePath(Application.ExeName))-4,
- length(openDialog.filename)-length(ExtractFilePath(Application.ExeName))+5);
- read;
- refresh;
- end;
-end;
-
-
-
-procedure TForm1.Button2Click(Sender: TObject);
-begin
-refresh;
-assignfile(translate,opendialog.filename,CP_UTF8);
-rewrite(translate);
-writeLn(translate, bom);
- for i := 1 to ie do
- if tstring[i]<>'' then
- begin
-cores:=false;
- for idx := 1 to idm do
-if (copy(dupes[idx],1,1)='[')
-and (dupes[idx]=ustring[i])
-and (Button3.caption='DUPES ON')
- then cores:=true;
- if cores=false then
- begin
- writeln(translate,ustring[i]);
- if copy(ustring[i],1,1)<>';' then
- writeln(translate,tstring[i]);
- end;
- end;
-closefile(translate);
-
- if (extractfilename(openDialog.filename)='=CORE=.txt')
- and (FileExists(ExtractFilePath(opendialog.filename)+'=DUPES=.txt')=true)
- then
- begin
-assignfile(translate,ExtractFilePath(opendialog.filename)+'=DUPES=.txt',CP_UTF8);
-rewrite(translate);
-writeLn(translate, bomd);
-for idx := 1 to idm do
-if (copy(dupes[idx],1,1)='[') then
- begin cores:=false;
- for i := 1 to ie do
- if dupes[idx]=ustring[i] then cores:=true;
- if cores=true then begin
- writeLn(translate, dupes[idx]);
- writeLn(translate, dupes[idx+1]);
- end;
- end;
-closefile(translate);
- end;
- read;
-end;
-
-procedure TForm1.Button3Click(Sender: TObject);
-begin
-if edit1.Text<>'' then
-If Button3.Caption='DUPES OFF'
-then Button3.Caption:='DUPES ON'
-else Button3.Caption:='DUPES OFF';
-refresh;read;refresh;
-end;
-
-procedure TForm1.CClick(Sender: TObject);
-begin
- Edit3.text:=edit2.text;
-end;
-
-procedure TForm1.XClick(Sender: TObject);
-begin
- Edit3.text:='';
- tstring[notranslate[strtoint(label2.caption)]]:='';
- refresh;
-end;
-
-procedure TForm1.enter(Sender: TObject; var Key: Word;
- Shift: TShiftState);
-begin
-case key of
- vk_return,vk_down: if listbox1.ItemIndex<listbox1.Items.Count then
- listbox1.ItemIndex:=listbox1.ItemIndex+1;
- vk_up: if listbox1.ItemIndex>0 then
- listbox1.ItemIndex:=listbox1.ItemIndex-1;
-end;
-refresh;
-end;
-
-procedure TForm1.ListBox1Click(Sender: TObject);
-begin
- refresh;
-end;
-
-procedure TForm1.FormCreate(Sender: TObject);
-begin
- KeyPreview := True;
-end;
-
end.
|