Changeset 9 for tools/Lazarus translator
- Timestamp:
- Jan 15, 2009, 9:47:30 AM (16 years ago)
- Location:
- tools/Lazarus translator
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/Lazarus translator/Translator.lpi
r7 r9 12 12 <VersionInfo> 13 13 <ProjectVersion Value=""/> 14 <Language Value=""/>15 <CharSet Value=""/>16 14 </VersionInfo> 17 15 <PublishOptions> … … 32 30 </Item1> 33 31 </RequiredPackages> 34 <Units Count="1 7">32 <Units Count="19"> 35 33 <Unit0> 36 34 <Filename Value="Translator.lpr"/> 37 35 <IsPartOfProject Value="True"/> 38 36 <UnitName Value="Translator"/> 39 <CursorPos X=" 30" Y="8"/>37 <CursorPos X="69" Y="18"/> 40 38 <TopLine Value="1"/> 41 <EditorIndex Value=" 1"/>42 <UsageCount Value=" 36"/>39 <EditorIndex Value="2"/> 40 <UsageCount Value="40"/> 43 41 <Loaded Value="True"/> 44 42 </Unit0> 45 43 <Unit1> 46 <Filename Value="U MainForm.pas"/>47 <ComponentName Value=" MainForm"/>44 <Filename Value="UItemListForm.pas"/> 45 <ComponentName Value="ItemListForm"/> 48 46 <IsPartOfProject Value="True"/> 49 47 <ResourceBaseClass Value="Form"/> 50 <ResourceFilename Value="U MainForm.lrs"/>51 <UnitName Value="U MainForm"/>52 <CursorPos X=" 25" Y="190"/>53 <TopLine Value=" 180"/>48 <ResourceFilename Value="UItemListForm.lrs"/> 49 <UnitName Value="UItemListForm"/> 50 <CursorPos X="11" Y="339"/> 51 <TopLine Value="324"/> 54 52 <EditorIndex Value="0"/> 55 <UsageCount Value=" 36"/>53 <UsageCount Value="40"/> 56 54 <Loaded Value="True"/> 57 55 </Unit1> … … 63 61 <ResourceFilename Value="UItemTranslationForm.lrs"/> 64 62 <UnitName Value="UItemTranslationForm"/> 65 <CursorPos X=" 23" Y="15"/>66 <TopLine Value=" 8"/>67 <EditorIndex Value=" 2"/>68 <UsageCount Value=" 36"/>63 <CursorPos X="8" Y="36"/> 64 <TopLine Value="16"/> 65 <EditorIndex Value="3"/> 66 <UsageCount Value="40"/> 69 67 <Loaded Value="True"/> 70 68 </Unit2> … … 75 73 <CursorPos X="1" Y="49"/> 76 74 <TopLine Value="43"/> 77 <UsageCount Value=" 36"/>75 <UsageCount Value="40"/> 78 76 </Unit3> 79 77 <Unit4> … … 97 95 <Unit7> 98 96 <Filename Value="..\..\..\..\..\..\Lazarus\fpc\2.2.2\source\rtl\objpas\sysutils\filutilh.inc"/> 99 <CursorPos X="1 0" Y="77"/>100 <TopLine Value="6 4"/>97 <CursorPos X="19" Y="78"/> 98 <TopLine Value="69"/> 101 99 <UsageCount Value="11"/> 102 100 </Unit7> … … 104 102 <Filename Value="..\..\..\..\..\..\Lazarus\fpc\2.2.2\source\rtl\win\sysutils.pp"/> 105 103 <UnitName Value="sysutils"/> 106 <CursorPos X=" 9" Y="256"/>107 <TopLine Value=" 252"/>104 <CursorPos X="11" Y="34"/> 105 <TopLine Value="13"/> 108 106 <UsageCount Value="11"/> 109 107 </Unit8> … … 142 140 <Unit14> 143 141 <Filename Value="..\..\..\..\..\..\Lazarus\fpc\2.2.2\source\rtl\objpas\sysutils\sysstrh.inc"/> 144 <CursorPos X="10" Y=" 83"/>145 <TopLine Value=" 70"/>142 <CursorPos X="10" Y="199"/> 143 <TopLine Value="186"/> 146 144 <UsageCount Value="13"/> 147 145 </Unit14> … … 159 157 <UsageCount Value="10"/> 160 158 </Unit16> 159 <Unit17> 160 <Filename Value="..\..\..\..\..\..\Lazarus\fpc\2.2.2\source\rtl\objpas\sysutils\sysutilh.inc"/> 161 <CursorPos X="12" Y="226"/> 162 <TopLine Value="212"/> 163 <UsageCount Value="10"/> 164 </Unit17> 165 <Unit18> 166 <Filename Value="UMainForm.pas"/> 167 <ComponentName Value="MainForm"/> 168 <IsPartOfProject Value="True"/> 169 <ResourceBaseClass Value="Form"/> 170 <ResourceFilename Value="UMainForm.lrs"/> 171 <UnitName Value="UMainForm"/> 172 <CursorPos X="36" Y="67"/> 173 <TopLine Value="56"/> 174 <EditorIndex Value="1"/> 175 <UsageCount Value="22"/> 176 <Loaded Value="True"/> 177 </Unit18> 161 178 </Units> 162 179 <JumpHistory Count="30" HistoryIndex="29"> 163 180 <Position1> 164 <Filename Value="U MainForm.pas"/>165 <Caret Line=" 132" Column="1" TopLine="119"/>181 <Filename Value="UItemListForm.pas"/> 182 <Caret Line="334" Column="1" TopLine="321"/> 166 183 </Position1> 167 184 <Position2> 168 <Filename Value="U MainForm.pas"/>169 <Caret Line=" 135" Column="1" TopLine="122"/>185 <Filename Value="UItemListForm.pas"/> 186 <Caret Line="328" Column="1" TopLine="315"/> 170 187 </Position2> 171 188 <Position3> 172 <Filename Value="U MainForm.pas"/>173 <Caret Line=" 136" Column="27" TopLine="124"/>189 <Filename Value="UItemListForm.pas"/> 190 <Caret Line="329" Column="1" TopLine="316"/> 174 191 </Position3> 175 192 <Position4> 176 <Filename Value="U MainForm.pas"/>177 <Caret Line=" 12" Column="20" TopLine="1"/>193 <Filename Value="UItemListForm.pas"/> 194 <Caret Line="330" Column="1" TopLine="317"/> 178 195 </Position4> 179 196 <Position5> 180 <Filename Value="U MainForm.pas"/>181 <Caret Line=" 167" Column="70" TopLine="154"/>197 <Filename Value="UItemListForm.pas"/> 198 <Caret Line="331" Column="1" TopLine="318"/> 182 199 </Position5> 183 200 <Position6> 184 <Filename Value="U MainForm.pas"/>185 <Caret Line=" 29" Column="48" TopLine="28"/>201 <Filename Value="UItemListForm.pas"/> 202 <Caret Line="332" Column="1" TopLine="319"/> 186 203 </Position6> 187 204 <Position7> 188 <Filename Value="U MainForm.pas"/>189 <Caret Line=" 134" Column="13" TopLine="131"/>205 <Filename Value="UItemListForm.pas"/> 206 <Caret Line="328" Column="1" TopLine="315"/> 190 207 </Position7> 191 208 <Position8> 192 <Filename Value="U MainForm.pas"/>193 <Caret Line=" 45" Column="22" TopLine="31"/>209 <Filename Value="UItemListForm.pas"/> 210 <Caret Line="329" Column="1" TopLine="316"/> 194 211 </Position8> 195 212 <Position9> 196 <Filename Value="U MainForm.pas"/>197 <Caret Line=" 176" Column="54" TopLine="169"/>213 <Filename Value="UItemListForm.pas"/> 214 <Caret Line="334" Column="1" TopLine="321"/> 198 215 </Position9> 199 216 <Position10> 200 <Filename Value="U MainForm.pas"/>201 <Caret Line=" 159" Column="1" TopLine="145"/>217 <Filename Value="UItemListForm.pas"/> 218 <Caret Line="335" Column="1" TopLine="322"/> 202 219 </Position10> 203 220 <Position11> 204 <Filename Value="U MainForm.pas"/>205 <Caret Line=" 134" Column="1" TopLine="126"/>221 <Filename Value="UItemListForm.pas"/> 222 <Caret Line="336" Column="1" TopLine="323"/> 206 223 </Position11> 207 224 <Position12> 208 <Filename Value="U MainForm.pas"/>209 <Caret Line=" 133" Column="1" TopLine="120"/>225 <Filename Value="UItemListForm.pas"/> 226 <Caret Line="328" Column="1" TopLine="315"/> 210 227 </Position12> 211 228 <Position13> 212 <Filename Value="U MainForm.pas"/>213 <Caret Line=" 134" Column="1" TopLine="121"/>229 <Filename Value="UItemListForm.pas"/> 230 <Caret Line="329" Column="1" TopLine="316"/> 214 231 </Position13> 215 232 <Position14> 216 <Filename Value="U MainForm.pas"/>217 <Caret Line=" 205" Column="48" TopLine="191"/>233 <Filename Value="UItemListForm.pas"/> 234 <Caret Line="334" Column="1" TopLine="321"/> 218 235 </Position14> 219 236 <Position15> 220 <Filename Value="U MainForm.pas"/>221 <Caret Line=" 133" Column="1" TopLine="120"/>237 <Filename Value="UItemListForm.pas"/> 238 <Caret Line="328" Column="1" TopLine="315"/> 222 239 </Position15> 223 240 <Position16> 224 <Filename Value="U MainForm.pas"/>225 <Caret Line=" 134" Column="1" TopLine="121"/>241 <Filename Value="UItemListForm.pas"/> 242 <Caret Line="329" Column="1" TopLine="316"/> 226 243 </Position16> 227 244 <Position17> 228 <Filename Value="U MainForm.pas"/>229 <Caret Line=" 204" Column="1" TopLine="191"/>245 <Filename Value="UItemListForm.pas"/> 246 <Caret Line="334" Column="1" TopLine="321"/> 230 247 </Position17> 231 248 <Position18> 232 <Filename Value="U MainForm.pas"/>233 <Caret Line=" 205" Column="1" TopLine="192"/>249 <Filename Value="UItemListForm.pas"/> 250 <Caret Line="328" Column="1" TopLine="315"/> 234 251 </Position18> 235 252 <Position19> 236 <Filename Value="U MainForm.pas"/>237 <Caret Line=" 229" Column="9" TopLine="205"/>253 <Filename Value="UItemListForm.pas"/> 254 <Caret Line="329" Column="1" TopLine="316"/> 238 255 </Position19> 239 256 <Position20> 240 <Filename Value="U MainForm.pas"/>241 <Caret Line=" 230" Column="1" TopLine="214"/>257 <Filename Value="UItemListForm.pas"/> 258 <Caret Line="330" Column="1" TopLine="317"/> 242 259 </Position20> 243 260 <Position21> 244 <Filename Value="U MainForm.pas"/>245 <Caret Line=" 135" Column="1" TopLine="122"/>261 <Filename Value="UItemListForm.pas"/> 262 <Caret Line="331" Column="1" TopLine="318"/> 246 263 </Position21> 247 264 <Position22> 248 <Filename Value="U MainForm.pas"/>249 <Caret Line=" 173" Column="1" TopLine="160"/>265 <Filename Value="UItemListForm.pas"/> 266 <Caret Line="332" Column="1" TopLine="319"/> 250 267 </Position22> 251 268 <Position23> 252 <Filename Value="U MainForm.pas"/>253 <Caret Line=" 174" Column="1" TopLine="161"/>269 <Filename Value="UItemListForm.pas"/> 270 <Caret Line="328" Column="1" TopLine="315"/> 254 271 </Position23> 255 272 <Position24> 256 <Filename Value="U MainForm.pas"/>257 <Caret Line=" 170" Column="25" TopLine="162"/>273 <Filename Value="UItemListForm.pas"/> 274 <Caret Line="329" Column="1" TopLine="316"/> 258 275 </Position24> 259 276 <Position25> 260 <Filename Value="U MainForm.pas"/>261 <Caret Line=" 135" Column="14" TopLine="120"/>277 <Filename Value="UItemListForm.pas"/> 278 <Caret Line="334" Column="1" TopLine="321"/> 262 279 </Position25> 263 280 <Position26> 264 <Filename Value=" Translator.lpr"/>265 <Caret Line=" 16" Column="34" TopLine="1"/>281 <Filename Value="UItemListForm.pas"/> 282 <Caret Line="335" Column="1" TopLine="322"/> 266 283 </Position26> 267 284 <Position27> 268 <Filename Value=" Translator.lpr"/>269 <Caret Line=" 19" Column="1" TopLine="1"/>285 <Filename Value="UItemListForm.pas"/> 286 <Caret Line="336" Column="1" TopLine="323"/> 270 287 </Position27> 271 288 <Position28> 272 <Filename Value=" Translator.lpr"/>273 <Caret Line=" 8" Column="30" TopLine="1"/>289 <Filename Value="UItemListForm.pas"/> 290 <Caret Line="328" Column="1" TopLine="315"/> 274 291 </Position28> 275 292 <Position29> 276 <Filename Value="U MainForm.pas"/>277 <Caret Line=" 104" Column="37" TopLine="44"/>293 <Filename Value="UItemListForm.pas"/> 294 <Caret Line="329" Column="1" TopLine="316"/> 278 295 </Position29> 279 296 <Position30> 280 <Filename Value="U MainForm.pas"/>281 <Caret Line=" 180" Column="21" TopLine="159"/>297 <Filename Value="UItemListForm.pas"/> 298 <Caret Line="334" Column="1" TopLine="321"/> 282 299 </Position30> 283 300 </JumpHistory> … … 298 315 </CompilerOptions> 299 316 <Debugging> 300 <BreakPoints Count=" 1">317 <BreakPoints Count="2"> 301 318 <Item1> 302 319 <Source Value="..\..\..\..\..\..\Lazarus\lcl\include\customlistview.inc"/> 303 320 <Line Value="518"/> 304 321 </Item1> 322 <Item2> 323 <Source Value="UItemListForm.pas"/> 324 <Line Value="328"/> 325 </Item2> 305 326 </BreakPoints> 306 327 <Exceptions Count="2"> -
tools/Lazarus translator/Translator.lpr
r4 r9 9 9 Interfaces, // this includes the LCL widgetset 10 10 Forms 11 { you can add units after this }, U MainForm, UItemTranslationForm,12 UTextFileStream ;11 { you can add units after this }, UItemListForm, UItemTranslationForm, 12 UTextFileStream, UMainForm; 13 13 14 14 begin 15 15 Application.Initialize; 16 16 Application.CreateForm(TMainForm, MainForm); 17 Application.CreateForm(TItemListForm, ItemListForm); 17 18 Application.CreateForm(TItemTranslationForm, ItemTranslationForm); 18 19 Application.Run; -
tools/Lazarus translator/UMainForm.lfm
r7 r9 1 1 object MainForm: TMainForm 2 Left = 2 453 Height = 5534 Top = 1 315 Width = 7286 Caption = ' Překlad Lazarusu'7 ClientHeight = 5538 ClientWidth = 7282 Left = 271 3 Height = 483 4 Top = 168 5 Width = 658 6 Caption = 'Seznam překladových souborů' 7 ClientHeight = 483 8 ClientWidth = 658 9 9 OnCreate = FormCreate 10 OnDestroy = FormDestroy11 OnShow = FormShow12 10 ParentFont = False 13 Position = poScreenCenter14 11 LCLVersion = '0.9.26' 15 12 object ListView1: TListView 16 Left = 817 Height = 51213 Left = 9 14 Height = 440 18 15 Top = 8 19 Width = 712 20 Anchors = [akTop, akLeft, akRight, akBottom] 16 Width = 632 21 17 Columns = < 22 18 item 23 Caption = 'Identifikace' 24 Width = 200 25 end 26 item 27 Caption = 'Původní text' 28 Width = 240 29 end 30 item 31 Caption = 'Přeložený text' 32 Width = 240 19 Caption = 'Název souboru' 20 Width = 400 33 21 end> 34 22 RowSelect = True 35 23 TabOrder = 0 36 24 ViewStyle = vsReport 37 OnColumnClick = ListView1ColumnClick38 OnCompare = ListView1Compare39 25 OnDblClick = ListView1DblClick 40 OnKeyPress = ListView1KeyPress41 26 end 42 object ProgressBar1: TProgressBar43 Left = 1 6044 Height = 2 045 Top = 52846 Width = 55847 Anchors = [akLeft, akRight, akBottom]48 Max = 10027 object Button1: TButton 28 Left = 10 29 Height = 25 30 Top = 456 31 Width = 198 32 Caption = 'Aktualizovat podle anglické verze' 33 OnClick = Button1Click 49 34 TabOrder = 1 50 35 end 51 object ComboBox1: TComboBox52 Left = 853 Height = 2154 Top = 52755 Width = 14456 ItemHeight = 1357 ItemIndex = 058 Items.Strings = (59 'lazaruside.cz.po'60 'objinspstrconsts.cz.po'61 'installerstrconsts.cz.po'62 'cgimodules.cz.po'63 'codetoolsstrconsts.cz.po'64 'h2passtrconsts.cz.po'65 'lclstrconsts.cz.po'66 'iputils.cz.po'67 )68 OnChange = ComboBox1Change69 Style = csDropDownList70 TabOrder = 271 Text = 'lazaruside.cz.po'72 end73 36 end -
tools/Lazarus translator/UMainForm.lrs
r7 r9 1 { T his is an automatically generated lazarus resource file}1 { Toto je automaticky generovaný zdrojový soubor lazarusu } 2 2 3 3 LazarusResources.Add('TMainForm','FORMDATA',[ 4 'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3#245#0#6'Height'#3')'#2#3'Top'#3#131 5 +#0#5'Width'#3#216#2#7'Caption'#6#17'P'#197#153'eklad Lazarusu'#12'ClientHeig' 6 +'ht'#3')'#2#11'ClientWidth'#3#216#2#8'OnCreate'#7#10'FormCreate'#9'OnDestroy' 7 +#7#11'FormDestroy'#6'OnShow'#7#8'FormShow'#10'ParentFont'#8#8'Position'#7#14 8 +'poScreenCenter'#10'LCLVersion'#6#6'0.9.26'#0#9'TListView'#9'ListView1'#4'Le' 9 +'ft'#2#8#6'Height'#3#0#2#3'Top'#2#8#5'Width'#3#200#2#7'Anchors'#11#5'akTop'#6 10 +'akLeft'#7'akRight'#8'akBottom'#0#7'Columns'#14#1#7'Caption'#6#12'Identifika' 11 +'ce'#5'Width'#3#200#0#0#1#7'Caption'#6#14'P'#197#175'vodn'#195#173' text'#5 12 +'Width'#3#240#0#0#1#7'Caption'#6#17'P'#197#153'elo'#197#190'en'#195#189' tex' 13 +'t'#5'Width'#3#240#0#0#0#9'RowSelect'#9#8'TabOrder'#2#0#9'ViewStyle'#7#8'vsR' 14 +'eport'#13'OnColumnClick'#7#20'ListView1ColumnClick'#9'OnCompare'#7#16'ListV' 15 +'iew1Compare'#10'OnDblClick'#7#17'ListView1DblClick'#10'OnKeyPress'#7#17'Lis' 16 +'tView1KeyPress'#0#0#12'TProgressBar'#12'ProgressBar1'#4'Left'#3#160#0#6'Hei' 17 +'ght'#2#20#3'Top'#3#16#2#5'Width'#3'.'#2#7'Anchors'#11#6'akLeft'#7'akRight'#8 18 +'akBottom'#0#3'Max'#2'd'#8'TabOrder'#2#1#0#0#9'TComboBox'#9'ComboBox1'#4'Lef' 19 +'t'#2#8#6'Height'#2#21#3'Top'#3#15#2#5'Width'#3#144#0#10'ItemHeight'#2#13#9 20 +'ItemIndex'#2#0#13'Items.Strings'#1#6#16'lazaruside.cz.po'#6#22'objinspstrco' 21 +'nsts.cz.po'#6#24'installerstrconsts.cz.po'#6#16'cgimodules.cz.po'#6#24'code' 22 +'toolsstrconsts.cz.po'#6#20'h2passtrconsts.cz.po'#6#18'lclstrconsts.cz.po'#6 23 +#13'iputils.cz.po'#0#8'OnChange'#7#15'ComboBox1Change'#5'Style'#7#14'csDropD' 24 +'ownList'#8'TabOrder'#2#2#4'Text'#6#16'lazaruside.cz.po'#0#0#0 4 'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3#15#1#6'Height'#3#227#1#3'Top'#3#168 5 +#0#5'Width'#3#146#2#7'Caption'#6#30'Seznam p'#197#153'ekladov'#195#189'ch so' 6 +'ubor'#197#175#12'ClientHeight'#3#227#1#11'ClientWidth'#3#146#2#8'OnCreate'#7 7 +#10'FormCreate'#10'ParentFont'#8#10'LCLVersion'#6#6'0.9.26'#0#9'TListView'#9 8 +'ListView1'#4'Left'#2#9#6'Height'#3#184#1#3'Top'#2#8#5'Width'#3'x'#2#7'Colum' 9 +'ns'#14#1#7'Caption'#6#14'N'#195#161'zev souboru'#5'Width'#3#144#1#0#0#9'Row' 10 +'Select'#9#8'TabOrder'#2#0#9'ViewStyle'#7#8'vsReport'#10'OnDblClick'#7#17'Li' 11 +'stView1DblClick'#0#0#7'TButton'#7'Button1'#4'Left'#2#10#6'Height'#2#25#3'To' 12 +'p'#3#200#1#5'Width'#3#198#0#7'Caption'#6'"Aktualizovat podle anglick'#195 13 +#169' verze'#7'OnClick'#7#12'Button1Click'#8'TabOrder'#2#1#0#0#0 25 14 ]); -
tools/Lazarus translator/UMainForm.pas
r7 r9 1 unit UMainForm; 1 unit UMainForm; 2 2 3 3 {$mode objfpc}{$H+} … … 7 7 uses 8 8 Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, 9 ComCtrls, UItemTranslationForm, UTextFileStream, StdCtrls; 10 11 const 12 TranslationFolder: string = '../../trunk/'; 13 TranslationMergeFileName: string = '../../tags/0.9.25/lazaruside.cz.po'; 9 ComCtrls, StdCtrls; 14 10 15 11 type 16 TTranslationItem = class 17 Identification: string; 18 OriginalText: string; 19 TranslatedText: string; 20 end; 12 13 { TForm1 } 21 14 22 15 { TMainForm } 23 16 24 17 TMainForm = class(TForm) 25 ComboBox1: TComboBox;18 Button1: TButton; 26 19 ListView1: TListView; 27 ProgressBar1: TProgressBar;28 20 procedure Button1Click(Sender: TObject); 29 procedure ComboBox1Change(Sender: TObject);30 procedure FormShow(Sender: TObject);31 procedure FormDestroy(Sender: TObject);32 21 procedure FormCreate(Sender: TObject); 33 procedure ListView1Compare(Sender: TObject; Item1, Item2: TListItem;34 Data: Integer; var Compare: Integer);35 22 procedure ListView1DblClick(Sender: TObject); 36 procedure ListView1KeyPress(Sender: TObject; var Key: Char);37 procedure ListView1ColumnClick(Sender: TObject; Column: TListColumn);38 23 private 39 LastFileName: string;40 procedure MergeListFromFile;24 procedure LoadTranslationList; 25 { private declarations } 41 26 public 42 LastSortedColumn: Integer; 43 StringList: TList; // TList<TText> 44 procedure FillList; 45 procedure LoadListFromFile; 46 procedure SaveListToFile; 47 end; 27 { public declarations } 28 end; 48 29 49 30 var 50 31 MainForm: TMainForm; 51 Ascending: Boolean;52 32 53 33 implementation 54 34 55 function SortByColumn(Item1, Item2: TListItem; Data: integer): Integer; stdcall; 35 uses 36 UItemListForm; 37 38 { TMainForm } 39 40 procedure TMainForm.ListView1DblClick(Sender: TObject); 56 41 begin 57 if Data = 0 then 58 Result := AnsiCompareText(Item1.Caption, Item2.Caption) 59 else 60 Result := AnsiCompareText(Item1.SubItems[Data - 1], 61 Item2.SubItems[Data - 1]); 62 if not Ascending then Result := -Result; 63 end; 64 65 procedure TMainForm.FillList; 66 var 67 I: Integer; 68 NewItem: TListItem; 69 CompletedCount: Integer; 70 begin 71 CompletedCount := 0; 72 with ListView1, Items do begin 73 BeginUpdate; 74 Clear; 75 for I := 0 to StringList.Count - 1 do 76 with TTranslationItem(StringList[I]) do begin 77 NewItem := Add; 78 NewItem.Data := StringList[I]; 79 NewItem.Caption := OriginalText; 80 with NewItem.SubItems do begin 81 Add(TranslatedText); 82 Add(Identification); 83 if TranslatedText <> '' then Inc(CompletedCount); 84 end; 42 if Assigned(ListView1.Selected) then begin 43 if not FileExists(TranslationFolder + ItemListForm.RenameToLocale(ListView1.Selected.Caption)) then begin 44 ForceDirectories(TranslationFolder + ExtractFileDir(ListView1.Selected.Caption)); 45 if FileExists(LazarusRepository + ListView1.Selected.Caption) then 46 FileCopy(LazarusRepository + ListView1.Selected.Caption, TranslationFolder + ItemListForm.RenameToLocale(ListView1.Selected.Caption)) 47 else raise Exception.Create('Zdrojový soubor ' + LazarusRepository + ListView1.Selected.Caption + ' nenalezen!'); 85 48 end; 86 EndUpdate; 49 ItemListForm.TranslationFile := TranslationFolder + ItemListForm.RenameToLocale(ListView1.Selected.Caption); 50 ItemListForm.ShowModal; 87 51 end; 88 ProgressBar1.Max := StringList.Count;89 ProgressBar1.Position := CompletedCount;90 52 end; 91 53 92 54 procedure TMainForm.FormCreate(Sender: TObject); 93 55 begin 94 StringList := TList.Create; 95 LastSortedColumn := -1; 96 Ascending := True; 56 LoadTranslationList; 97 57 end; 98 58 99 procedure TMainForm.ListView1Compare(Sender: TObject; Item1, Item2: TListItem; 100 Data: Integer; var Compare: Integer); 101 begin 102 Compare := AnsiCompareText(Item1.SubItems[0], 103 Item2.SubItems[0]); 104 if not Ascending then Compare := -Compare; 105 end; 106 107 procedure TMainForm.FormDestroy(Sender: TObject); 59 procedure TMainForm.Button1Click(Sender: TObject); 108 60 var 109 61 I: Integer; 110 62 begin 111 SaveListToFile; 112 for I := 0 to StringList.Count - 1 do 113 TTranslationItem(StringList[I]).Free; 114 StringList.Free; 115 end; 116 117 procedure TMainForm.FormShow(Sender: TObject); 118 begin 119 LoadListFromFile; 120 //MergeListFromFile; 121 FillList; 122 end; 123 124 procedure TMainForm.Button1Click(Sender: TObject); 125 begin 126 ListView1.SortColumn := 1; 127 ListView1.SortType := stData; 128 ListView1.Refresh; 129 ListView1.Invalidate; 130 end; 131 132 procedure TMainForm.ComboBox1Change(Sender: TObject); 133 begin 134 SaveListToFile; 135 LoadListFromFile; 136 FillList; 137 end; 138 139 procedure TMainForm.ListView1ColumnClick(Sender: TObject; Column: TListColumn); 140 begin 141 if Column.Index = LastSortedColumn then 142 Ascending := not Ascending 143 else 144 LastSortedColumn := Column.Index; 145 //TListView(Sender).CustomSort(@SortByColumn, Column.Index); 146 end; 147 148 procedure TMainForm.ListView1DblClick(Sender: TObject); 149 begin 150 if Assigned(ListView1.Selected) then 151 with ItemTranslationForm, TTranslationItem(ListView1.Selected.Data) do begin 152 Memo1.Text := OriginalText; 153 Memo2.Text := TranslatedText; 154 ItemTranslationForm.ShowModal; 155 //OriginalText := Memo1.Text; 156 TranslatedText := Copy(Memo2.Text, 1, Length(Memo2.Text) - 2); 157 158 ListView1.Selected.SubItems[0] := TranslatedText; 159 SaveListToFile; 63 for I := 0 to High(LanguageFiles) do begin 64 ForceDirectories(TranslationFolder + ExtractFileDir(LanguageFiles[I])); 65 ItemListForm.TranslationFile := LazarusRepository + LanguageFiles[I]; 66 ItemListForm.LoadListFromFile; 67 ItemListForm.TranslationFile := TranslationFolder + ItemListForm.RenameToLocale(LanguageFiles[I]); 68 ItemListForm.MergeListFromFile; 69 ItemListForm.SaveListToFile; 160 70 end; 161 71 end; 162 72 163 procedure TMainForm.ListView1KeyPress(Sender: TObject; var Key: Char); 73 procedure TMainForm.LoadTranslationList; 74 var 75 I: Integer; 76 NewItem: TListItem; 164 77 begin 165 if Key = #13 then ListView1DblClick(Self); 166 end; 167 168 procedure TMainForm.LoadListFromFile; 169 var 170 Source: TTextFileStream; 171 Row: string; 172 NewItem: TTranslationItem; 173 I: Integer; 174 begin 175 StringList.Clear; 176 LastFileName := TranslationFolder + ComboBox1.Text; 177 NewItem := nil; 178 Source := TTextFileStream.Create(LastFileName, fmOpenRead); 179 try 180 for I := 0 to 11 do Row := Source.ReadLn; // Skip leading info lines 181 182 while not Source.Eof do begin 183 Row := Source.ReadLn; 184 if Copy(Row, 1, 2) = '#:' then begin 185 NewItem := TTranslationItem.Create; 186 NewItem.Identification := Copy(Row, 4, 255); 187 end else 188 if Copy(Row, 1, Pos(' ', Row) - 1) = 'msgid' then begin 189 if Assigned(NewItem) then 190 NewItem.OriginalText := Copy(Row, 8, Length(Row) - 8) 191 end else 192 if Copy(Row, 1, Pos(' ', Row) - 1) = 'msgstr' then begin 193 NewItem.TranslatedText := Copy(Row, 9, Length(Row) - 9); 194 StringList.Add(NewItem); 195 end; 196 end; 197 finally 198 Source.Free; 78 ListView1.Items.Clear; 79 for I := 0 to High(LanguageFiles) do begin 80 NewItem := ListView1.Items.Add; 81 NewItem.Caption := LanguageFiles[I] 199 82 end; 200 83 end; 201 202 procedure TMainForm.SaveListToFile;203 var204 Source: TTextFileStream;205 I: Integer;206 begin207 Source := TTextFileStream.Create(LastFileName, fmOpenWrite);208 with Source do209 try210 WriteLn('msgid ""');211 WriteLn('msgstr ""');212 WriteLn('"Project-Id-Version: \n"');213 WriteLn('"POT-Creation-Date: \n"');214 WriteLn('"PO-Revision-Date: 2009-01-07 19:03+0100\n"');215 WriteLn('"Last-Translator: Chronos <robie@centrum.cz>\n"');216 WriteLn('"Translation-Source: http://tv.zdechov.net/svn/lazarus_czech/\n"');217 WriteLn('"Language-Team: \n"');218 WriteLn('"MIME-Version: 1.0\n"');219 WriteLn('"Content-Type: text/plain; charset=UTF-8\n"');220 WriteLn('"Content-Transfer-Encoding: 8bit\n"');221 WriteLn('');222 for I := 0 to StringList.Count - 1 do223 with TTranslationItem(StringList[I]) do begin224 WriteLn('#: ' + Identification);225 WriteLn('msgid "' + OriginalText + '"');226 WriteLn('msgstr "' + TranslatedText + '"');227 WriteLn('');228 end;229 finally230 Source.Free;231 end;232 end;233 234 procedure TMainForm.MergeListFromFile;235 var236 Source: TTextFileStream;237 Row: string;238 NewItem: TTranslationItem;239 I: Integer;240 begin241 NewItem := nil;242 Source := TTextFileStream.Create(TranslationMergeFileName, fmOpenRead);243 try244 for I := 0 to 10 do Row := Source.ReadLn; // Skip lines245 246 while not Source.Eof do begin247 Row := Source.ReadLn;248 if Copy(Row, 1, 2) = '#:' then begin249 NewItem := TTranslationItem.Create;250 NewItem.Identification := Copy(Row, 4, 255);251 end else252 if Copy(Row, 1, Pos(' ', Row) - 1) = 'msgid' then253 NewItem.OriginalText := Copy(Row, 8, Length(Row) - 8)254 else255 if Copy(Row, 1, Pos(' ', Row) - 1) = 'msgstr' then begin256 NewItem.TranslatedText := Copy(Row, 9, Length(Row) - 9);257 I := 0;258 while (I < StringList.Count) and ((TTranslationItem(StringList[I]).OriginalText <> NewItem.OriginalText) or259 (TTranslationItem(StringList[I]).Identification <> NewItem.Identification)) do Inc(I);260 if I < StringList.Count then261 TTranslationItem(StringList[I]).TranslatedText := NewItem.TranslatedText;262 NewItem.Free;263 end;264 end;265 finally266 Source.Free;267 end;268 end;269 270 84 271 85 initialization
Note:
See TracChangeset
for help on using the changeset viewer.