Ignore:
Timestamp:
Jan 14, 2009, 8:20:25 AM (16 years ago)
Author:
george
Message:
  • Přidáno: Překladový soubor pro inspektor objektů a instalátor.
  • Přidáno: Podpora pro překlad více souborů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/Lazarus translator/UMainForm.pas

    r4 r6  
    77uses
    88  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
    9   ComCtrls, UItemTranslationForm, UTextFileStream;
     9  ComCtrls, UItemTranslationForm, UTextFileStream, StdCtrls;
    1010
    1111const
    12   TranslationFileName: string = '../../trunk/lazaruside.cz.po';
     12  TranslationFolder: string = '../../trunk/';
    1313  TranslationMergeFileName: string = '../../tags/0.9.25/lazaruside.cz.po';
    1414
     
    2323
    2424  TMainForm = class(TForm)
     25    ComboBox1: TComboBox;
    2526    ListView1: TListView;
    2627    ProgressBar1: TProgressBar;
     28    procedure Button1Click(Sender: TObject);
     29    procedure ComboBox1Change(Sender: TObject);
    2730    procedure FormShow(Sender: TObject);
    2831    procedure FormDestroy(Sender: TObject);
    2932    procedure FormCreate(Sender: TObject);
     33    procedure ListView1Compare(Sender: TObject; Item1, Item2: TListItem;
     34      Data: Integer; var Compare: Integer);
    3035    procedure ListView1DblClick(Sender: TObject);
    3136    procedure ListView1KeyPress(Sender: TObject; var Key: Char);
    3237    procedure ListView1ColumnClick(Sender: TObject; Column: TListColumn);
    3338  private
     39    LastFileName: string;
    3440    procedure MergeListFromFile;
    3541  public
     
    7177      NewItem := Add;
    7278      NewItem.Data := StringList[I];
    73       NewItem.Caption := Identification;
     79      NewItem.Caption := OriginalText;
    7480      with NewItem.SubItems do begin
    75         Add(OriginalText);
    7681        Add(TranslatedText);
     82        Add(Identification);
    7783        if TranslatedText <> '' then Inc(CompletedCount);
    7884      end;
     
    8995  LastSortedColumn := -1;
    9096  Ascending := True;
     97end;
     98
     99procedure TMainForm.ListView1Compare(Sender: TObject; Item1, Item2: TListItem;
     100  Data: Integer; var Compare: Integer);
     101begin
     102    Compare := AnsiCompareText(Item1.SubItems[0],
     103      Item2.SubItems[0]);
     104  if not Ascending then Compare := -Compare;
    91105end;
    92106
     
    106120  //MergeListFromFile;
    107121  FillList;
    108   //ListView1.CustomSort(@SortByColumn, 1);
     122end;
     123
     124procedure TMainForm.Button1Click(Sender: TObject);
     125begin
     126  ListView1.SortColumn := 1;
     127  ListView1.SortType := stData;
     128  ListView1.Refresh;
     129  ListView1.Invalidate;
     130end;
     131
     132procedure TMainForm.ComboBox1Change(Sender: TObject);
     133begin
     134  SaveListToFile;
     135  LoadListFromFile;
     136  FillList;
    109137end;
    110138
     
    128156    TranslatedText := Copy(Memo2.Text, 1, Length(Memo2.Text) - 2);
    129157
    130     ListView1.Selected.SubItems[1] := TranslatedText;
     158    ListView1.Selected.SubItems[0] := TranslatedText;
    131159    SaveListToFile;
    132160  end;
     
    145173  I: Integer;
    146174begin
     175  StringList.Clear;
     176  LastFileName := TranslationFolder + ComboBox1.Text;
    147177  NewItem := nil;
    148   Source := TTextFileStream.Create(TranslationFileName, fmOpenRead);
     178  Source := TTextFileStream.Create(LastFileName, fmOpenRead);
    149179  try
    150180    for I := 0 to 10 do Row := Source.ReadLn;  // Skip leading info lines
     
    175205  I: Integer;
    176206begin
    177   Source := TTextFileStream.Create(TranslationFileName, fmOpenWrite);
     207  Source := TTextFileStream.Create(LastFileName, fmOpenWrite);
    178208  with Source do
    179209  try
     
    184214    WriteLn('"PO-Revision-Date: 2009-01-07 19:03+0100\n"');
    185215    WriteLn('"Last-Translator: Chronos <robie@centrum.cz>\n"');
     216    WriteLn('"Translation-Source: http://tv.zdechov.net/svn/lazarus_czech/\n"');
    186217    WriteLn('"Language-Team: \n"');
    187218    WriteLn('"MIME-Version: 1.0\n"');
    188     WriteLn('"Content-Type: text/plain; charset=windows-1250\n"');
     219    WriteLn('"Content-Type: text/plain; charset=UTF-8\n"');
    189220    WriteLn('"Content-Transfer-Encoding: 8bit\n"');
    190221    WriteLn('');
Note: See TracChangeset for help on using the changeset viewer.