From 7acd60188e06cde1d82fa2c4774eba8e5dc7b000 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Fri, 20 Dec 2013 10:45:02 +0000 Subject: LangPackMgr update (from Jebifor) git-svn-id: http://svn.miranda-ng.org/main/trunk@7295 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- tools/langpackmgr/Unit1.pas | 284 +++++++++++++++++++++----------------- tools/langpackmgr/langpackmgr.lpr | 4 +- tools/langpackmgr/langpackmgr.lps | 96 +++++++------ tools/langpackmgr/unit1.lfm | 16 +-- 4 files changed, 224 insertions(+), 176 deletions(-) (limited to 'tools/langpackmgr') diff --git a/tools/langpackmgr/Unit1.pas b/tools/langpackmgr/Unit1.pas index 6de5df25fc..86a7dae5ed 100644 --- a/tools/langpackmgr/Unit1.pas +++ b/tools/langpackmgr/Unit1.pas @@ -15,7 +15,7 @@ type button2: tbutton; button3: tbutton; button4: tbutton; - CheckBox1: TCheckBox; + Label1: TLabel; memo1: tmemo; memo2: tmemo; listbox: tlistbox; @@ -43,7 +43,9 @@ type var form1: tform1; - locale: string; + + view,locale: string; + trlang,trline: TStringList; z,j,i,l:integer; sr:tsearchrec; res:integer; @@ -51,7 +53,7 @@ var u:array[0..6000] of integer; first:string; filename:string; - im,m:integer; + m:integer; sse:string; implementation @@ -59,8 +61,37 @@ implementation { tform1 } +procedure tform1.formcreate(sender: tobject); + var sr:tsearchrec; res:integer; +begin +view:='english'; +trlang:=TstringList.Create; +trline:=TstringList.Create; + if (paramstr(1)='-r') then + begin + form1.caption:='Miranda NG Langpack Tools: Replacer'; + end + else + begin + res:=findfirst(extractfilepath(application.exename)+'*',faanyfile,sr); + while res = 0 do + begin + if ((sr.attr and fadirectory)=fadirectory) + and ((sr.name='.')or(sr.name='..')) then + begin res:=findnext(sr); continue; end; + if ((sr.attr and fadirectory)=fadirectory) + and (fileexists(extractfilepath(application.exename)+ + '/'+sr.name+'/=head=.txt')) and (sr.name<>'english') then + begin + ListBox.items.add(sr.name); + trlang.add(sr.name); + end; + res:=findnext(sr); + end; + SysUtils.FindClose(sr); - + end; +end; procedure tform1.stringlist; var llist:TStringList; @@ -103,15 +134,17 @@ procedure tform1.stringlist; procedure tform1.stringview; begin - sse:=copy(s[0,u[listbox.itemindex]],2, - length(s[0,u[listbox.itemindex]])-2); + for i:=0 to combobox2.items.count-1 do + if view=combobox2.Items[i] then + combobox2.itemindex:=i; + sse:=trline[combobox2.ItemIndex]; m:=1; - for im := 1 to length(sse)-1 do + for i := 1 to length(sse)-1 do begin - if copy(sse,im,2)='\n' then + if copy(sse,i,2)='\n' then begin - memo1.Lines.Add(copy(sse,m,im-m)); - m:=im+2; + memo1.Lines.Add(copy(sse,m,i-m)); + m:=i+2; end; end; memo2.Lines.Clear; @@ -121,94 +154,73 @@ procedure tform1.stringview; if s[1,u[listbox.itemindex]]<>'' then begin m:=1; - for im := 1 to length(s[1,u[listbox.itemindex]])-1 do + for i := 1 to length(s[1,u[listbox.itemindex]])-1 do begin - if copy(s[1,u[listbox.itemindex]],im,2)='\n' then + if copy(s[1,u[listbox.itemindex]],i,2)='\n' then begin - memo2.Lines.Add(copy(s[1,u[listbox.itemindex]],m,im-m)); - m:=im+2; + memo2.Lines.Add(copy(s[1,u[listbox.itemindex]],m,i-m)); + m:=i+2; end; end; if m=1 then memo2.Lines.Add(s[1,u[listbox.itemindex]]) else memo2.Lines.Add(copy(s[1,u[listbox.itemindex]],m, length(s[1,u[listbox.itemindex]])-m+2)); end; - end; + end; procedure tform1.savestring; var sa:integer; -begin - s[1,u[l]]:=''; - for sa:=0 to memo2.Lines.Count-1 do - begin - s[1,u[l]]:=s[1,u[l]]+memo2.Lines[sa]; - if sa<>memo2.Lines.Count-1 then s[1,u[l]]:=s[1,u[l]]+'\n'; - end; -end; - -procedure tform1.formcreate(sender: tobject); - var - sr:tsearchrec; - res:integer; -begin - if (paramstr(1)='-r') then - begin - form1.caption:='Miranda NG Langpack Tools: Replacer'; - - end else begin - res:=findfirst(extractfilepath(application.exename)+'*',faanyfile,sr); - while res = 0 do - begin - if ((sr.attr and fadirectory)=fadirectory) - and ((sr.name='.')or(sr.name='..')) then - begin res:=findnext(sr); continue; end; - if ((sr.attr and fadirectory)=fadirectory) - and (fileexists(extractfilepath(application.exename)+ - '/'+sr.name+'/=head=.txt')) and (sr.name<>'english') then - ListBox.items.add(sr.name); - res:=findnext(sr); - end; - SysUtils.FindClose(sr); -end; - -end; + s[1,u[l]]:=''; + for sa:=0 to memo2.Lines.Count-1 do + begin + s[1,u[l]]:=s[1,u[l]]+memo2.Lines[sa]; + if sa<>memo2.Lines.Count-1 then s[1,u[l]]:=s[1,u[l]]+'\n'; + end; + end; procedure tform1.combobox1change(sender: tobject); - var - f:textfile; + var f:textfile; begin if not FileExists(extractfilePath(application.exename) +'/'+locale+'/'+combobox1.items[combobox1.itemindex]+'.txt') - then + then begin - assignfile(f,extractfilePath(application.exename) - +'/'+locale+'/'+combobox1.items[combobox1.itemindex]+'.txt'); - rewrite(f); - closefile(f); + assignfile(f,extractfilePath(application.exename) + +'/'+locale+'/'+combobox1.items[combobox1.itemindex]+'.txt'); + rewrite(f); + closefile(f); end; - stringlist; - memo1.lines.clear; - memo2.lines.clear; + stringlist; + memo1.lines.clear; + memo2.lines.clear; end; procedure tform1.ComboBox2Change(Sender: TObject); begin - + view:=combobox2.Text; + if (listbox.items.count>0) and (combobox1.items.count>0) then + begin + savestring; + memo1.lines.Clear; + memo2.lines.Clear; + stringview; + end; end; procedure tform1.Button1Click(Sender: TObject); var sList:TStringList; - begin - savestring; - sList:=TstringList.Create; - sList.add(first); - for i := 0 to j do - begin - if copy(s[0,i],1,1)=';' then - sList.add(s[0,i]); - if s[1,i]<>'' then - begin +begin + savestring; + memo1.lines.Clear; + memo2.lines.Clear; + sList:=TstringList.Create; + sList.add(first); + for i := 0 to j do + begin + if copy(s[0,i],1,1)=';' then sList.add(s[0,i]); + if s[1,i]<>'' then + begin sList.add(s[0,i]); sList.add(s[1,i]); end @@ -223,11 +235,32 @@ procedure tform1.Button1Click(Sender: TObject); sList.SavetoFile(extractfilePath(application.exename) +'/'+locale+'/'+filename+'.txt'); sList.free; - stringview; + stringlist; +end; + +procedure tform1.Button2Click(Sender: TObject); + var search:TStringList; q:integer; +begin + search:=TstringList.Create; + search.LoadFromFile(extractfilePath(application.exename)+ + '/'+locale+'/'+'Langpack_'+locale+'.txt'); + for q := 0 to listbox.items.Count-1 do + for i := 1 to search.count-1 do + if (s[0,u[q]]=search[i])and(copy(search[i+1],1,1)<>'[')then + begin + s[1,u[q]]:=search[i+1]; + break; + end; + search.free; +end; + +procedure tform1.Button3Click(Sender: TObject); +begin + memo2.lines:=memo1.lines; end; procedure tform1.Button4Click(Sender: TObject); - var str:utf8string; i:integer; + var str:widestring; i:integer; begin str:='http://translate.google.com/?hl=&ie=yhgg#auto/'; if locale='belarusian' then str:=str+'be/'; @@ -253,52 +286,56 @@ procedure tform1.Button4Click(Sender: TObject); if locale='ukrainian' then str:=str+'uk/'; for i:=0 to memo1.Lines.Count-1 do begin - str:=str+memo1.Lines[i]; - if i'[')then - begin - s[1,u[q]]:=search[i+1]; - break; - end; -search.free; -end; - -procedure tform1.Button3Click(Sender: TObject); -begin -memo2.lines:=memo1.lines; -end; - procedure tform1.ListBox1Click(sender: tobject); +var search:TStringList; r:integer; begin if (form1.caption<>'Miranda NG Langpack Tools: Editor') then begin savestring; + search:=tstringlist.Create; + combobox2.items.clear; + trline.Clear; + combobox2.items.add('english'); + trline.add(copy(s[0,u[listbox.itemindex]],2, + length(s[0,u[listbox.itemindex]])-2)); + for i:=0 to trlang.count-1 do + begin + if (fileexists(extractfilepath(application.exename)+ + '/'+trlang[i]+'/'+filename+'.txt')) + and(trlang[i]<>locale) then + begin + search.LoadFromFile(extractfilepath(application.exename)+ + '/'+trlang[i]+'/'+filename+'.txt'); + for r:=1 to search.Count-2 do + if (search[r]=s[0,u[listbox.itemindex]]) + and (search[r+1]<>'') + and (search[r+1]<>'[') + and (search[r+1]<>';') + then begin + combobox2.items.add(trlang[i]); + trline.add(search[r+1]); + break; + end; + end; + end; + search.free; + combobox2.itemindex:=0; memo1.lines.clear; memo2.lines.clear; -{} stringview; end; end; procedure tform1.listbox2click(sender: tobject); - var - sr:tsearchrec; - res:integer; + var sr:tsearchrec; res:integer; begin if form1.caption='Miranda NG Langpack Tools: Editor' then @@ -308,30 +345,29 @@ begin ListBox.items.clear; combobox1.items.add('=CORE='); res:=findfirst(extractfilepath(application.exename) - +'\english\plugins\*.txt', faanyfile, sr); - while res = 0 do - begin - combobox1.items.add('plugins\'+copy(extractfilename(sr.name),1, - length(extractfilename(sr.name))-4)); - res:=findnext(sr); - end; - SysUtils.FindClose(sr); - res:=findfirst(extractfilepath(application.exename) - +'\english\weather\*.txt', faanyfile, sr); - while res = 0 do - begin - combobox1.items.add('weather\'+copy(extractfilename(sr.name),1, - length(extractfilename(sr.name))-4)); - res:=findnext(sr); - end; - SysUtils.FindClose(sr); + +'\english\plugins\*.txt', faanyfile, sr); + while res = 0 do + begin + combobox1.items.add('plugins\'+copy(extractfilename(sr.name),1, + length(extractfilename(sr.name))-4)); + res:=findnext(sr); + end; + SysUtils.FindClose(sr); + res:=findfirst(extractfilepath(application.exename) + +'\english\weather\*.txt', faanyfile, sr); + while res = 0 do + begin + combobox1.items.add('weather\'+copy(extractfilename(sr.name),1, + length(extractfilename(sr.name))-4)); + res:=findnext(sr); + end; + SysUtils.FindClose(sr); + combobox1.itemindex:=0; + stringlist; + if (fileexists(extractfilePath(application.exename)+'/'+locale+'/' + +'Langpack_'+locale+'.txt')) then button2.Enabled:=true; end; - combobox1.itemindex:=0; - stringlist; - if (fileexists(extractfilePath(application.exename)+'/'+locale+'/' - +'Langpack_'+locale+'.txt')) then button2.Enabled:=true; - end; end. diff --git a/tools/langpackmgr/langpackmgr.lpr b/tools/langpackmgr/langpackmgr.lpr index 2de2b5decd..3e8e7cf2ea 100644 --- a/tools/langpackmgr/langpackmgr.lpr +++ b/tools/langpackmgr/langpackmgr.lpr @@ -7,8 +7,8 @@ uses cthreads, {$ENDIF}{$ENDIF} Interfaces, // this includes the LCL widgetset - Forms, unit1 - { you can add units after this }; + Forms, unit1; + {$R *.res} diff --git a/tools/langpackmgr/langpackmgr.lps b/tools/langpackmgr/langpackmgr.lps index e6fe26509f..e478dbdbb6 100644 --- a/tools/langpackmgr/langpackmgr.lps +++ b/tools/langpackmgr/langpackmgr.lps @@ -4,17 +4,16 @@ - + - - - + + @@ -24,148 +23,163 @@ + - - - + + + + + + + + + + + - - + + - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + diff --git a/tools/langpackmgr/unit1.lfm b/tools/langpackmgr/unit1.lfm index 1f572fc5f7..cf741b9ecd 100644 --- a/tools/langpackmgr/unit1.lfm +++ b/tools/langpackmgr/unit1.lfm @@ -57,7 +57,6 @@ object Form1: TForm1 Height = 21 Top = 8 Width = 72 - Enabled = False ItemHeight = 13 ItemIndex = 0 Items.Strings = ( @@ -130,13 +129,12 @@ object Form1: TForm1 ) TabOrder = 9 end - object CheckBox1: TCheckBox - Left = 400 - Height = 17 - Top = 12 - Width = 104 - Caption = 'Other languages:' - Enabled = False - TabOrder = 10 + object Label1: TLabel + Left = 448 + Height = 14 + Top = 15 + Width = 61 + Caption = 'Other langs:' + ParentColor = False end end -- cgit v1.2.3