[Initranslator-svncheckins] SF.net SVN: initranslator: [262] translator/trunk/src
Brought to you by:
peter3
|
From: <pe...@us...> - 2007-10-20 12:49:28
|
Revision: 262
http://initranslator.svn.sourceforge.net/initranslator/?rev=262&view=rev
Author: peter3
Date: 2007-10-20 05:49:32 -0700 (Sat, 20 Oct 2007)
Log Message:
-----------
- access to SectionStart, SectionEnd and SeparatorChars from ini file (special use)
Modified Paths:
--------------
translator/trunk/src/AppOptions.pas
translator/trunk/src/MainFrm.pas
translator/trunk/src/OptionsFrm.dfm
translator/trunk/src/OptionsFrm.pas
translator/trunk/src/TranslateFile.pas
Modified: translator/trunk/src/AppOptions.pas
===================================================================
--- translator/trunk/src/AppOptions.pas 2007-10-20 12:48:11 UTC (rev 261)
+++ translator/trunk/src/AppOptions.pas 2007-10-20 12:49:32 UTC (rev 262)
@@ -135,6 +135,9 @@
FHeader:TTntStrings;
FFontSize:integer;
FFontName:WideString;
+ FSectionEnd: WideString;
+ FSectionStart: WideString;
+ FSeparatorChars: WideString;
procedure ReadWindowInfos(ini:TWideCustomIniFile);
procedure WriteWindowInfos(ini:TWideCustomIniFile);
function GetWindowInfo(AForm:TForm):TAppWindowInfo;
@@ -144,6 +147,9 @@
procedure SetHeader(const Value:TTntStrings);
function GetOption(const Section, Name:WideString):WideString;
procedure SetOption(const Section, Name, Value:WideString);
+ procedure SetSectionEnd(const Value: WideString);
+ procedure SetSectionStart(const Value: WideString);
+ procedure SetSeparatorChars(const Value: WideString);
public
constructor Create(const AFilename:WideString);
destructor Destroy; override;
@@ -219,6 +225,10 @@
property ColorFontEvenRow:TColor read FColorFontEvenRow write FColorFontEvenRow;
property ColorOddRow:TColor read FColorOddRow write FColorOddRow;
property ColorFontOddRow:TColor read FColorFontOddRow write FColorFontOddRow;
+
+ property SeparatorChars:WideString read FSeparatorChars write SetSeparatorChars;
+ property SectionStart:WideString read FSectionStart write SetSectionStart;
+ property SectionEnd:WideString read FSectionEnd write SetSectionEnd;
end;
implementation
@@ -550,6 +560,11 @@
ColorOddRow := ini.ReadInteger('Colors', 'ColorOddRow', $FFFFFF);
ColorFontOddRow := ini.ReadInteger('Colors', 'ColorFontOddRow', $000000);
+ SeparatorChars := ini.ReadString('Parsing','SeparatorChars','=');
+ SectionStart := ini.ReadString('Parsing','SectionStart','[');
+ SectionEnd := ini.ReadString('Parsing','SectionEnd',']');
+
+
ReadWindowInfos(ini);
FTools.LoadFromIni(ini);
finally
@@ -649,6 +664,11 @@
ini.WriteInteger('Colors', 'ColorOddRow', ColorOddRow);
ini.WriteInteger('Colors', 'ColorFontOddRow', ColorFontOddRow);
+
+ ini.WriteString('Parsing','SeparatorChars',SeparatorChars);
+ ini.WriteString('Parsing','SectionStart',SectionStart);
+ ini.WriteString('Parsing','SectionEnd',SectionEnd);
+
WriteWindowInfos(ini);
FTools.SaveToIni(ini);
ini.UpdateFile;
@@ -750,4 +770,25 @@
end;
end;
+procedure TAppOptions.SetSectionEnd(const Value: WideString);
+begin
+ FSectionEnd := Value;
+ if FSectionEnd = '' then
+ FSectionEnd := ']';
+end;
+
+procedure TAppOptions.SetSectionStart(const Value: WideString);
+begin
+ FSectionStart := Value;
+ if FSectionStart = '' then
+ FSectionStart := '[';
+end;
+
+procedure TAppOptions.SetSeparatorChars(const Value: WideString);
+begin
+ FSeparatorChars := Value;
+ if FSeparatorChars = '' then
+ FSeparatorChars := '=';
+end;
+
end.
Modified: translator/trunk/src/MainFrm.pas
===================================================================
--- translator/trunk/src/MainFrm.pas 2007-10-20 12:48:11 UTC (rev 261)
+++ translator/trunk/src/MainFrm.pas 2007-10-20 12:49:32 UTC (rev 262)
@@ -749,6 +749,9 @@
acSpellCheck.Tag := 0;
acSpellCheck.OnExecute := SpellCheckExecute;
{$ENDIF}
+ FTranslateFile.StartSection := GlobalAppOptions.SectionStart[1];
+ FTranslateFile.EndSection := GlobalAppOptions.SectionEnd[1];
+ FTranslateFile.SeparatorChars := GlobalAppOptions.SeparatorChars;
end;
procedure TfrmMain.SaveSettings;
Modified: translator/trunk/src/OptionsFrm.dfm
===================================================================
--- translator/trunk/src/OptionsFrm.dfm 2007-10-20 12:48:11 UTC (rev 261)
+++ translator/trunk/src/OptionsFrm.dfm 2007-10-20 12:49:32 UTC (rev 262)
@@ -1,7 +1,7 @@
object frmOptions: TfrmOptions
Left = 316
Top = 175
- ActiveControl = chkGlobalPath
+ ActiveControl = chkShowQuotes
BorderStyle = bsDialog
Caption = 'Preferences'
ClientHeight = 449
@@ -65,7 +65,7 @@
Top = 2
Width = 477
Height = 387
- ActivePage = tsAdvanced
+ ActivePage = tsGeneral
Anchors = [akLeft, akTop, akRight, akBottom]
TabOrder = 3
object tsGeneral: TTntTabSheet
Modified: translator/trunk/src/OptionsFrm.pas
===================================================================
--- translator/trunk/src/OptionsFrm.pas 2007-10-20 12:48:11 UTC (rev 261)
+++ translator/trunk/src/OptionsFrm.pas 2007-10-20 12:49:32 UTC (rev 262)
@@ -212,6 +212,12 @@
pnlFontPreview.Font.Size := Options.FontSize;
reHeader.Lines := Options.Header;
reFooter.Lines := Options.Footer;
+
+{
+ edSeparatorChars.Text := Options.SeparatorChars;
+ edSectionStart.Text := Options.SectionStart;
+ edSectionEnd.Text := Options.SectionEnd;
+}
UpdateFontList;
end;
@@ -242,6 +248,12 @@
Options.Header := reHeader.Lines;
Options.Footer := reFooter.Lines;
+
+{
+ Options.SeparatorChars := edSeparatorChars.Text;
+ Options.SectionStart := edSectionStart.Text;
+ Options.SectionEnd := edSectionEnd.Text;
+}
end;
procedure TfrmOptions.GetFonts(Strings:TTntStrings);
Modified: translator/trunk/src/TranslateFile.pas
===================================================================
--- translator/trunk/src/TranslateFile.pas 2007-10-20 12:48:11 UTC (rev 261)
+++ translator/trunk/src/TranslateFile.pas 2007-10-20 12:49:32 UTC (rev 262)
@@ -129,6 +129,7 @@
property Items[Index: integer]: ITranslationItem read GetItem; default;
property TranslatedCount: integer read GetTranslatedCount write SetTranslatedCount;
property Modified: WordBool read GetModified write SetModified;
+
end;
TTranslateFiles = class
@@ -137,7 +138,7 @@
FOrphans: ITranslationItems;
FEndSection: WideChar;
FStartSection: WideChar;
- FSeparatorChar: WideChar;
+ FSeparatorChars: WideString;
FHeader: WideString;
FFooter: WideString;
FCommentChars: TTntStrings;
@@ -158,7 +159,7 @@
// 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 SeparatorChar: WideChar read FSeparatorChar write FSeparatorChar default '=';
+ property SeparatorChars: WideString read FSeparatorChars write FSeparatorChars;
property CommentChars: TTntStrings read FCommentChars;
end;
@@ -505,7 +506,7 @@
FOrphans := TTranslationItems.Create;
StartSection := '[';
EndSection := ']';
- SeparatorChar := '=';
+ SeparatorChars := '=';
FCommentChars.Add(';');
FCommentChars.Add('//');
FCommentChars.Add('#');
@@ -533,6 +534,17 @@
Result := false;
end;
+function WideTextContains(SubStr:WideString; Str:WideString):integer;
+var i:integer;
+begin
+ for i := 1 to Length(SubStr) do
+ begin
+ Result := WideTExtPos(SubStr[i], Str);
+ if Result > 0 then Exit;
+ end;
+ Result := 0;
+end;
+
function TTranslateFiles.LoadOriginal(const Filename: WideString; Encoding: TEncoding): TEncoding;
var
S, FComments: TTntStringlist;
@@ -575,9 +587,9 @@
FComments.Add(tmpString)
else if WideStartsText(StartSection, tmpTrimString) and WideEndsText(EndSection, tmpTrimString) then
ASection := Copy(tmpTrimString, 2, Length(tmpTrimString) - 2)
- else if (WideTextPos(SeparatorChar, tmpString) > 1) then
+ else if WideTextContains(SeparatorChars, tmpString) > 1 then
begin
- j := WideTextPos(SeparatorChar, tmpString);
+ j := WideTextContains(SeparatorChars, tmpString);
if j > 1 then
begin
with FItems.Add do
@@ -644,7 +656,7 @@
ASection := Copy(tmpTrimString, 2, Length(tmpTrimString) - 2)
else
begin
- j := WideTextPos(SeparatorChar, tmpString);
+ j := WideTextContains(SeparatorChars, tmpString);
if j > 1 then
begin
k := FItems.IndexOf(ASection, Copy(tmpString, 1, j - 1));
@@ -711,7 +723,8 @@
end;
if not NewSection then
FixAndAddComments(S, Items[i].OrigComments);
- S.Add(Items[i].Name + SeparatorChar + Items[i].Original);
+
+ S.Add(Items[i].Name + Copy(SeparatorChars,1,1) + Items[i].Original);
end;
if Footer <> '' then
S.Add(trim(Footer));
@@ -760,7 +773,7 @@
end;
if not NewSection then
FixAndAddComments(S, Items[i].TransComments);
- S.Add(Items[i].Name + SeparatorChar + Items[i].Translation);
+ S.Add(Items[i].Name + TCommonUtils.StrDefault(Copy(SeparatorChars,1,1),'=') + Items[i].Translation);
end;
if Footer <> '' then
S.Add(trim(Footer));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|