[Initranslator-svncheckins] SF.net SVN: initranslator: [152] translator/trunk
Brought to you by:
peter3
|
From: <pe...@us...> - 2006-12-03 15:18:17
|
Revision: 152
http://svn.sourceforge.net/initranslator/?rev=152&view=rev
Author: peter3
Date: 2006-12-03 07:00:23 -0800 (Sun, 03 Dec 2006)
Log Message:
-----------
- More comment indicators supported (; // and #)
- Comments are now saved verbatim
Modified Paths:
--------------
translator/trunk/description.txt
translator/trunk/src/CommentsFrm.pas
translator/trunk/src/MainFrm.pas
translator/trunk/src/TranslateFile.pas
Modified: translator/trunk/description.txt
===================================================================
--- translator/trunk/description.txt 2006-12-03 12:40:09 UTC (rev 151)
+++ translator/trunk/description.txt 2006-12-03 15:00:23 UTC (rev 152)
@@ -4,22 +4,25 @@
Ini Translator is a small Windows tool to simplify the translation of ini style language files (as used by programs like FlashGet, Inno Setup, ISTool and Wallpaper Sequencer to name a few) and the GUI is similar to that of poEdit (a translation editor for gnu gettext).
Some of it's main features are:
-- Uses Troy Wolbrinks TNT controls for (hopefully) correct display regardless of locale
+- Uses Troy Wolbrinks TNT controls for correct display regardless of locale
- Uses Jordan Russell's Toolbar2000 (http://www.jrsoftware.org) for that slick look
- Uses Alex Denisov's TBX enhancements to Toolbar2000 (http://g32.org)
- Uses TBX Themes created by Roy Magne Klever and others (http://www.rmklever.com)
+- Uses SpTBX for Unicode support in toolbars and menus (http://club.telepolis.com/silverpointdev/sptbxlib/index.htm)
- Uses Addictive Software's Addict spell checker (http://www.addictivesoftware.com)
-- Dictionary support w. auto-translation
+- Dictionaries with support for auto-translation, inversion and multiple translations for each item
- Sorting of original/translation column
- Monitoring of external changes to open files
- Quick jump to next/previous untranslated item
+- Quickly find "conspicious" items (configurable)
- Command line interface with "script"-capability
- Search and Replace
-- Comment viewer
+- Comment viewer and editor
- Bookmark support
- Support for loading/saving using different encodings (ANSI, UTF-8, Unicode)
-- Localizable using ini-style language files ;)
+- Localizable using ini-style language files
- Plugin support for loading and saving to any conceivable file-format
+- Many plugins included to read and write many popular and common file formats
Ini Translator is hosted at sourceforge and is released under the MPL 1.1 license.
@@ -33,6 +36,7 @@
Jordan Russell's Toolbar2000 can be found at http://www.jrsoftware.org
Alex Denisov's TBX enhancements to Toolbar2000 can be found at http://g32.org
TBX Themes by Roy Magne Klever and others can be found at http://www.rmklever.com
+SpTBXLib from Silverpoint Development can be found at http://club.telepolis.com/silverpointdev/sptbxlib/index.htm
Note that these libraries are free to use for non-commercial development but might have restrictions if you use them in any other way. Check the links above for more info.
Modified: translator/trunk/src/CommentsFrm.pas
===================================================================
--- translator/trunk/src/CommentsFrm.pas 2006-12-03 12:40:09 UTC (rev 151)
+++ translator/trunk/src/CommentsFrm.pas 2006-12-03 15:00:23 UTC (rev 152)
@@ -25,7 +25,7 @@
Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls,
Menus, StdActns, ActnList, Buttons,
BaseForm, TranslateFile, TransIntf,
- TntComCtrls, TntButtons, TntStdCtrls, TntExtCtrls, TntMenus,
+ TntClasses, TntComCtrls, TntButtons, TntStdCtrls, TntExtCtrls, TntMenus,
TntStdActns, TntActnList, TB2Item, TBX, SpTBXItem;
type
@@ -67,7 +67,7 @@
{ Private declarations }
public
{ Public declarations }
- procedure SetComments(const Item: ITranslationItem; CommentChar: WideChar);
+ procedure SetComments(const Item: ITranslationItem; CommentChars: TTntStrings);
property Pinned: boolean read GetPinned write SetPinned;
property OnCommentModified: TCommentModifiedEvent read FOnCommentModified write SetOnCommentModified;
end;
@@ -90,7 +90,7 @@
reOriginal.Height := H div 2;
end;
-procedure TfrmComments.SetComments(const Item: ITranslationItem; CommentChar: WideChar);
+procedure TfrmComments.SetComments(const Item: ITranslationItem; CommentChars: TTntStrings);
var i: integer;
begin
if Item = nil then
@@ -100,15 +100,15 @@
end
else
begin
- reOriginal.Text := trim(Item.OrigComments);
- for i := 0 to reOriginal.Lines.Count - 1 do
- if Copy(reOriginal.Lines[i], 1, 1) = CommentChar then
- reOriginal.Lines[i] := trim(Copy(reOriginal.Lines[i], 2, MaxInt));
+ reOriginal.Text := Item.OrigComments;
+// for i := 0 to reOriginal.Lines.Count - 1 do
+// if Copy(reOriginal.Lines[i], 1, 1) = CommentChar then
+// reOriginal.Lines[i] := trim(Copy(reOriginal.Lines[i], 2, MaxInt));
reTranslation.OnChange := nil;
- reTranslation.Text := trim(Item.TransComments);
- for i := 0 to reTranslation.Lines.Count - 1 do
- if Copy(reTranslation.Lines[i], 1, 1) = CommentChar then
- reTranslation.Lines[i] := trim(Copy(reTranslation.Lines[i], 2, MaxInt));
+ reTranslation.Text := Item.TransComments;
+// for i := 0 to reTranslation.Lines.Count - 1 do
+// if Copy(reTranslation.Lines[i], 1, 1) = CommentChar then
+// reTranslation.Lines[i] := trim(Copy(reTranslation.Lines[i], 2, MaxInt));
reTranslation.Modified := false;
reTranslation.OnChange := reTranslationChange;
end;
Modified: translator/trunk/src/MainFrm.pas
===================================================================
--- translator/trunk/src/MainFrm.pas 2006-12-03 12:40:09 UTC (rev 151)
+++ translator/trunk/src/MainFrm.pas 2006-12-03 15:00:23 UTC (rev 152)
@@ -2424,12 +2424,12 @@
reTranslation.Modified := false;
if frmComments <> nil then
begin
- frmComments.SetComments(FTranslateFile.Items[Item.Index], FTranslateFile.CommentChar);
+ frmComments.SetComments(FTranslateFile.Items[Item.Index], FTranslateFile.CommentChars);
frmComments.OnCommentModified := DoCommentModified;
end;
end
else if frmComments <> nil then
- frmComments.SetComments(nil, FTranslateFile.CommentChar);
+ frmComments.SetComments(nil, FTranslateFile.CommentChars);
UpdateStatus;
end;
@@ -3039,36 +3039,38 @@
var
P: TPoint;
AInfoTip: WideString;
+ AItem:ITranlsationItem;
begin
InfoTip := '';
AInfoTip := '';
if Item <> nil then
begin
GetCursorPos(P);
+ AItem := FTranslateFile.Items[Item.Index];
if PtInRect(Rect(Left, Top, Left + Width div 2, Height), P) then
begin
- if trim(FTranslateFile.Items[Item.Index].OrigComments) <> '' then
- AInfoTip := _(ClassName, SOriginal) + ':'#13#10 + trim(FTranslateFile.Items[Item.Index].OrigComments)
+ if trim(AItem.OrigComments) <> '' then
+ AInfoTip := _(ClassName, SOriginal) + ':'#13#10 + trim(AItem.OrigComments)
else
- AInfoTip := FTranslateFile.Items[Item.Index].Original;
+ AInfoTip := AItem.Original;
end
else if PtInRect(Rect(Left + Width div 2, Top, Left + Width, Height), P) then
begin
- if trim(FTranslateFile.Items[Item.Index].TransComments) <> '' then
- AInfoTip := _(ClassName, STranslation) + ':'#13#10 + trim(FTranslateFile.Items[Item.Index].TransComments)
+ if trim(AItem.TransComments) <> '' then
+ AInfoTip := _(ClassName, STranslation) + ':'#13#10 + trim(AItem.TransComments)
else
- AInfoTip := FTranslateFile.Items[Item.Index].Translation;
+ AInfoTip := AItem.Translation;
end
else
begin
- if trim(FTranslateFile.Items[Item.Index].OrigComments) <> '' then
- AInfoTip := _(ClassName, SOriginal) + ':'#13#10 + trim(FTranslateFile.Items[Item.Index].OrigComments) +
+ if trim(AItem.OrigComments) <> '' then
+ AInfoTip := _(ClassName, SOriginal) + ':'#13#10 + trim(AItem.OrigComments) +
#13#10#13#10;
- if trim(FTranslateFile.Items[Item.Index].TransComments) <> '' then
+ if trim(AItem.TransComments) <> '' then
AInfoTip := _(ClassName, STranslation) + ':'#13#10 +
- trim(FTranslateFile.Items[Item.Index].TransComments);
+ trim(AItem.TransComments);
if AInfoTip = '' then
- AInfoTip := FTranslateFile.Items[Item.Index].Original + ' - ' + FTranslateFile.Items[Item.Index].Translation;
+ AInfoTip := AItem.Original + ' - ' + AItem.Translation;
end;
end;
InfoTip := AInfoTip;
@@ -3452,7 +3454,7 @@
procedure TfrmMain.DoCommentModified(Sender: TObject;
const AText: WideString);
- function MakeComment(const S: WideString): WideString;
+{ function MakeComment(const S: WideString): WideString;
var
CChar: WideChar;
begin
@@ -3461,10 +3463,11 @@
while (Length(Result) > 0) and (Result[Length(Result)] = CChar) do
SetLength(Result, Length(Result) - 1);
end;
+ }
begin
if SelectedListItem <> nil then
with SelectedListItem do
- FTranslateFile.Items[Index].TransComments := MakeComment(AText);
+ FTranslateFile.Items[Index].TransComments := AText;
end;
procedure TfrmMain.UpdateColumn(Index: integer; const AFileName: WideString);
Modified: translator/trunk/src/TranslateFile.pas
===================================================================
--- translator/trunk/src/TranslateFile.pas 2006-12-03 12:40:09 UTC (rev 151)
+++ translator/trunk/src/TranslateFile.pas 2006-12-03 15:00:23 UTC (rev 152)
@@ -23,7 +23,7 @@
interface
uses
- Classes, SysUtils, AppConsts, AppUtils, TransIntf, TNTSysUtils;
+ Classes, SysUtils, AppConsts, AppUtils, TransIntf, TntClasses, TntSysUtils;
type
TTranslationItems = class;
@@ -135,12 +135,12 @@
private
FItems: ITranslationItems;
FOrphans: ITranslationItems;
- FCommentChar: WideChar;
FEndSection: WideChar;
FStartSection: WideChar;
FSeparatorChar: WideChar;
FHeader: WideString;
FFooter: WideString;
+ FCommentChars: TTntStrings;
public
constructor Create;
destructor Destroy; override;
@@ -158,13 +158,13 @@
// various delimiters used to parse the file (should probably not be changed)
property StartSection: WideChar read FStartSection write FStartSection default '[';
property EndSection: WideChar read FEndSection write FEndSection default ']';
- property CommentChar: WideChar read FCommentChar write FCommentChar default ';';
property SeparatorChar: WideChar read FSeparatorChar write FSeparatorChar default '=';
+ property CommentChars: TTntStrings read FCommentChars;
end;
implementation
uses
- Windows, TntSystem, TntClasses;
+ Windows, TntSystem;
function trimQuotes(const S: WideString; Quote: WideChar): WideString;
begin
@@ -500,12 +500,15 @@
constructor TTranslateFiles.Create;
begin
inherited Create;
+ FCommentChars := TTntStringlist.Create;
FItems := TTranslationItems.Create;
FOrphans := TTranslationItems.Create;
StartSection := '[';
EndSection := ']';
SeparatorChar := '=';
- CommentChar := ';';
+ FCommentChars.Add(';');
+ FCommentChars.Add('//');
+ FCommentChars.Add('#');
end;
destructor TTranslateFiles.Destroy;
@@ -517,6 +520,18 @@
inherited;
end;
+function InStringList(List: TTntStrings; const Value: WideString): boolean;
+var i: integer;
+begin
+ for i := 0 to List.Count - 1 do
+ if WideTextPos(List[i], Value) = 1 then
+ begin
+ Result := true;
+ Exit;
+ end;
+ Result := false;
+end;
+
function TTranslateFiles.LoadOriginal(const Filename: WideString; Encoding: TEncoding): TEncoding;
var
S, FComments: TTntStringlist;
@@ -552,11 +567,11 @@
end;
for i := 0 to S.Count - 1 do
begin
- if WideTextPos(CommentChar, S[i]) = 1 then
+ if InStringList(CommentChars, S[i]) then
FComments.Add(S[i])
- else if (WideTextPos(StartSection, S[i]) = 1) and (WideTextPos(EndSection, S[i]) = Length(S[i])) and (WideTextPos(SeparatorChar, S[i]) = 0) then
+ else if (WideTextPos(StartSection, S[i]) = 1) and (WideTextPos(EndSection, S[i]) = Length(S[i])) then
ASection := Copy(S[i], 2, Length(S[i]) - 2)
- else
+ else if (WideTextPos(SeparatorChar, S[i]) > 1) then
begin
j := WideTextPos(SeparatorChar, S[i]);
if j > 1 then
@@ -570,7 +585,9 @@
FComments.Clear;
end;
end;
- end;
+ end
+ else
+ FComments.Add(S[i]);
end;
finally
S.Free;
@@ -615,7 +632,7 @@
end;
for i := 0 to S.Count - 1 do
begin
- if WideTextPos(CommentChar, S[i]) = 1 then
+ if InStringList(CommentChars, S[i]) then
FComments.Add(S[i])
else if (WideTextPos(StartSection, S[i]) = 1) and (WideTextPos(EndSection, S[i]) = Length(S[i]))
and (WideTextPos(SeparatorChar, S[i]) = 0) then
@@ -638,6 +655,8 @@
begin
FItem := FOrphans.Add;
FItem.Section := ASection;
+ FItem.Name := Copy(S[i], 1, j - 1);
+
FItem.Original := Copy(S[i], 1, j - 1);
FItem.Translation := Copy(S[i], j + 1, MaxInt);
// normal behavior is to regard empty translations as untranslated
@@ -656,16 +675,9 @@
end;
procedure FixAndAddComments(S: TTntStringlist; const Comments: WideString);
-var tmp: WideString;
begin
- if trim(Comments) <> '' then
- begin
- S.Add('');
- tmp := trim(Comments);
- if tmp[1] <> ';' then
- tmp := '; ' + tmp;
- S.Add(tmp);
- end;
+ if Comments <> '' then
+ S.Add(Comments);
end;
procedure TTranslateFiles.SaveOriginal(const Filename: WideString; Encoding: TEncoding);
@@ -947,3 +959,4 @@
end;
end.
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|