Move Translations unit from LCL to LazUtils.

git-svn-id: trunk@53740 -
This commit is contained in:
juha 2016-12-20 22:32:43 +00:00
parent b1a91e3d7c
commit 2329f266ed
7 changed files with 386 additions and 368 deletions

2
.gitattributes vendored
View File

@ -3086,6 +3086,7 @@ components/lazutils/test/TestLazStorageMem.lpi svneol=native#text/plain
components/lazutils/test/TestLazStorageMem.lpr svneol=native#text/plain components/lazutils/test/TestLazStorageMem.lpr svneol=native#text/plain
components/lazutils/test/testlazstoragememcase1.pas svneol=native#text/plain components/lazutils/test/testlazstoragememcase1.pas svneol=native#text/plain
components/lazutils/textstrings.pas svneol=native#text/pascal components/lazutils/textstrings.pas svneol=native#text/pascal
components/lazutils/translations.pas svneol=native#text/pascal
components/lazutils/ttcache.pas svneol=native#text/pascal components/lazutils/ttcache.pas svneol=native#text/pascal
components/lazutils/ttcalc.pas svneol=native#text/pascal components/lazutils/ttcalc.pas svneol=native#text/pascal
components/lazutils/ttcalc1.inc svneol=native#text/pascal components/lazutils/ttcalc1.inc svneol=native#text/pascal
@ -7990,7 +7991,6 @@ lcl/tests/test6_1masks.lpr svneol=native#text/plain
lcl/themes.pas svneol=native#text/pascal lcl/themes.pas svneol=native#text/pascal
lcl/tmschema.pas svneol=native#text/pascal lcl/tmschema.pas svneol=native#text/pascal
lcl/toolwin.pp svneol=native#text/pascal lcl/toolwin.pp svneol=native#text/pascal
lcl/translations.pas svneol=native#text/pascal
lcl/update_allunits.lpi svneol=native#text/plain lcl/update_allunits.lpi svneol=native#text/plain
lcl/update_allunits.lpr svneol=native#text/plain lcl/update_allunits.lpr svneol=native#text/plain
lcl/utrace.pp svneol=native#text/pascal lcl/utrace.pp svneol=native#text/pascal

View File

@ -27,6 +27,7 @@ function DbgStr(const StringWithSpecialChars: string): string; overload;
function DbgStr(const StringWithSpecialChars: string; StartPos, Len: PtrInt): string; overload; function DbgStr(const StringWithSpecialChars: string; StartPos, Len: PtrInt): string; overload;
function DbgStr(const p: PChar; Len: PtrInt): string; overload; function DbgStr(const p: PChar; Len: PtrInt): string; overload;
function DbgWideStr(const StringWithSpecialChars: widestring): string; overload; function DbgWideStr(const StringWithSpecialChars: widestring): string; overload;
procedure DumpExceptionBackTrace;
function ConvertLineEndings(const s: string): string; function ConvertLineEndings(const s: string): string;
procedure ReplaceSubstring(var s: string; StartPos, Count: SizeInt; procedure ReplaceSubstring(var s: string; StartPos, Count: SizeInt;
@ -765,6 +766,30 @@ begin
end; end;
end; end;
procedure DumpAddr(Addr: Pointer);
begin
// preventing another exception, while dumping stack trace
try
DebugLn(BackTraceStrFunc(Addr));
except
DebugLn(SysBackTraceStr(Addr));
end;
end;
procedure DumpExceptionBackTrace;
var
FrameCount: integer;
Frames: PPointer;
FrameNumber:Integer;
begin
DebugLn(' Stack trace:');
DumpAddr(ExceptAddr);
FrameCount:=ExceptFrameCount;
Frames:=ExceptFrames;
for FrameNumber := 0 to FrameCount-1 do
DumpAddr(Frames[FrameNumber]);
end;
function ConvertLineEndings(const s: string): string; function ConvertLineEndings(const s: string): string;
var var
i: Integer; i: Integer;

View File

@ -16,7 +16,7 @@
<Description Value="Useful units for Lazarus packages."/> <Description Value="Useful units for Lazarus packages."/>
<License Value="Modified LGPL-2"/> <License Value="Modified LGPL-2"/>
<Version Major="1"/> <Version Major="1"/>
<Files Count="89"> <Files Count="90">
<Item1> <Item1>
<Filename Value="LazLoggerImpl.inc"/> <Filename Value="LazLoggerImpl.inc"/>
<Type Value="Include"/> <Type Value="Include"/>
@ -262,117 +262,121 @@
<UnitName Value="TextStrings"/> <UnitName Value="TextStrings"/>
</Item61> </Item61>
<Item62> <Item62>
<Filename Value="ttcache.pas"/> <Filename Value="translations.pas"/>
<UnitName Value="TTCache"/> <UnitName Value="Translations"/>
</Item62> </Item62>
<Item63> <Item63>
<Filename Value="ttcalc.pas"/> <Filename Value="ttcache.pas"/>
<UnitName Value="TTCalc"/> <UnitName Value="TTCache"/>
</Item63> </Item63>
<Item64> <Item64>
<Filename Value="ttcalc1.inc"/> <Filename Value="ttcalc.pas"/>
<Type Value="Include"/> <UnitName Value="TTCalc"/>
</Item64> </Item64>
<Item65> <Item65>
<Filename Value="ttcalc2.inc"/> <Filename Value="ttcalc1.inc"/>
<Type Value="Include"/> <Type Value="Include"/>
</Item65> </Item65>
<Item66> <Item66>
<Filename Value="ttcalc3.inc"/> <Filename Value="ttcalc2.inc"/>
<Type Value="Include"/> <Type Value="Include"/>
</Item66> </Item66>
<Item67> <Item67>
<Filename Value="ttcalc4.inc"/> <Filename Value="ttcalc3.inc"/>
<Type Value="Include"/> <Type Value="Include"/>
</Item67> </Item67>
<Item68> <Item68>
<Filename Value="ttcmap.pas"/> <Filename Value="ttcalc4.inc"/>
<UnitName Value="TTCMap"/> <Type Value="Include"/>
</Item68> </Item68>
<Item69> <Item69>
<Filename Value="ttconfig.inc"/> <Filename Value="ttcmap.pas"/>
<Type Value="Include"/> <UnitName Value="TTCMap"/>
</Item69> </Item69>
<Item70> <Item70>
<Filename Value="ttdebug.pas"/> <Filename Value="ttconfig.inc"/>
<UnitName Value="TTDebug"/> <Type Value="Include"/>
</Item70> </Item70>
<Item71> <Item71>
<Filename Value="tterror.pas"/> <Filename Value="ttdebug.pas"/>
<UnitName Value="TTError"/> <UnitName Value="TTDebug"/>
</Item71> </Item71>
<Item72> <Item72>
<Filename Value="ttfile.pas"/> <Filename Value="tterror.pas"/>
<UnitName Value="TTFile"/> <UnitName Value="TTError"/>
</Item72> </Item72>
<Item73> <Item73>
<Filename Value="ttgload.pas"/> <Filename Value="ttfile.pas"/>
<UnitName Value="TTGLoad"/> <UnitName Value="TTFile"/>
</Item73> </Item73>
<Item74> <Item74>
<Filename Value="ttinterp.pas"/> <Filename Value="ttgload.pas"/>
<UnitName Value="TTInterp"/> <UnitName Value="TTGLoad"/>
</Item74> </Item74>
<Item75> <Item75>
<Filename Value="ttload.pas"/> <Filename Value="ttinterp.pas"/>
<UnitName Value="TTLoad"/> <UnitName Value="TTInterp"/>
</Item75> </Item75>
<Item76> <Item76>
<Filename Value="ttmemory.pas"/> <Filename Value="ttload.pas"/>
<UnitName Value="TTMemory"/> <UnitName Value="TTLoad"/>
</Item76> </Item76>
<Item77> <Item77>
<Filename Value="ttobjs.pas"/> <Filename Value="ttmemory.pas"/>
<UnitName Value="TTObjs"/> <UnitName Value="TTMemory"/>
</Item77> </Item77>
<Item78> <Item78>
<Filename Value="ttprofile.pas"/> <Filename Value="ttobjs.pas"/>
<UnitName Value="TTProfile"/> <UnitName Value="TTObjs"/>
</Item78> </Item78>
<Item79> <Item79>
<Filename Value="ttraster.pas"/> <Filename Value="ttprofile.pas"/>
<UnitName Value="TTRASTER"/> <UnitName Value="TTProfile"/>
</Item79> </Item79>
<Item80> <Item80>
<Filename Value="ttraster_sweep.inc"/> <Filename Value="ttraster.pas"/>
<Type Value="Include"/> <UnitName Value="TTRASTER"/>
</Item80> </Item80>
<Item81> <Item81>
<Filename Value="tttables.pas"/> <Filename Value="ttraster_sweep.inc"/>
<UnitName Value="TTTables"/> <Type Value="Include"/>
</Item81> </Item81>
<Item82> <Item82>
<Filename Value="tttypes.pas"/> <Filename Value="tttables.pas"/>
<UnitName Value="TTTypes"/> <UnitName Value="TTTables"/>
</Item82> </Item82>
<Item83> <Item83>
<Filename Value="unixfileutil.inc"/> <Filename Value="tttypes.pas"/>
<Type Value="Include"/> <UnitName Value="TTTypes"/>
</Item83> </Item83>
<Item84> <Item84>
<Filename Value="unixlazfileutils.inc"/> <Filename Value="unixfileutil.inc"/>
<Type Value="Include"/> <Type Value="Include"/>
</Item84> </Item84>
<Item85> <Item85>
<Filename Value="unixlazutf8.inc"/> <Filename Value="unixlazfileutils.inc"/>
<Type Value="Include"/> <Type Value="Include"/>
</Item85> </Item85>
<Item86> <Item86>
<Filename Value="utf8process.pp"/> <Filename Value="unixlazutf8.inc"/>
<UnitName Value="UTF8Process"/> <Type Value="Include"/>
</Item86> </Item86>
<Item87> <Item87>
<Filename Value="winfileutil.inc"/> <Filename Value="utf8process.pp"/>
<Type Value="Include"/> <UnitName Value="UTF8Process"/>
</Item87> </Item87>
<Item88> <Item88>
<Filename Value="winlazfileutils.inc"/> <Filename Value="winfileutil.inc"/>
<Type Value="Include"/> <Type Value="Include"/>
</Item88> </Item88>
<Item89> <Item89>
<Filename Value="winlazutf8.inc"/> <Filename Value="winlazfileutils.inc"/>
<Type Value="Include"/> <Type Value="Include"/>
</Item89> </Item89>
<Item90>
<Filename Value="winlazutf8.inc"/>
<Type Value="Include"/>
</Item90>
</Files> </Files>
<LazDoc Paths="../../docs/xml/lazutils"/> <LazDoc Paths="../../docs/xml/lazutils"/>
<i18n> <i18n>

View File

@ -18,9 +18,9 @@ uses
LazLoggerProfiling, LazMethodList, LazUnicode, LazUTF16, LazUTF8, LazLoggerProfiling, LazMethodList, LazUnicode, LazUTF16, LazUTF8,
LazUTF8Classes, LazUTF8SysUtils, LazUtilities, LazUtilsStrConsts, LazUTF8Classes, LazUTF8SysUtils, LazUtilities, LazUtilsStrConsts,
LConvEncoding, lcsvutils, LookupStringList, Maps, Masks, PasWString, LConvEncoding, lcsvutils, LookupStringList, Maps, Masks, PasWString,
StringHashList, TextStrings, TTCache, TTCalc, TTCMap, TTDebug, TTError, StringHashList, TextStrings, Translations, TTCache, TTCalc, TTCMap, TTDebug,
TTFile, TTGLoad, TTInterp, TTLoad, TTMemory, TTObjs, TTProfile, TTRASTER, TTError, TTFile, TTGLoad, TTInterp, TTLoad, TTMemory, TTObjs, TTProfile,
TTTables, TTTypes, UTF8Process, LazarusPackageIntf; TTRASTER, TTTables, TTTypes, UTF8Process, LazarusPackageIntf;
implementation implementation

View File

@ -81,17 +81,13 @@ unit Translations;
{$mode objfpc}{$H+}{$INLINE ON} {$mode objfpc}{$H+}{$INLINE ON}
{$include include/lcl_defines.inc}
interface interface
uses uses
Classes, SysUtils, Classes, SysUtils,
{$IF FPC_FULLVERSION>=30001}jsonscanner,{$ENDIF} jsonparser, fpjson, {$IF FPC_FULLVERSION>=30001}jsonscanner,{$ENDIF} jsonparser, fpjson,
// LCL
LCLProc,
// LazUtils // LazUtils
FileUtil, LazFileUtils, LazUTF8, LazUTF8Classes, LConvEncoding, FileUtil, LazFileUtils, LazUTF8, LazUTF8Classes, LConvEncoding, LazLogger,
AvgLvlTree, StringHashList; AvgLvlTree, StringHashList;
type type
@ -613,7 +609,7 @@ begin
Result:=true; Result:=true;
except except
on e: Exception do begin on e: Exception do begin
{$IFNDEF DisableChecks} {$IFnDEF DisableChecks}
DebugLn('Exception while translating ', ResUnitName); DebugLn('Exception while translating ', ResUnitName);
DebugLn(e.Message); DebugLn(e.Message);
DumpExceptionBackTrace; DumpExceptionBackTrace;
@ -648,7 +644,7 @@ begin
Result:=true; Result:=true;
except except
on e: Exception do begin on e: Exception do begin
{$IFNDEF DisableChecks} {$IFnDEF DisableChecks}
DebugLn('Exception while translating:'); DebugLn('Exception while translating:');
DebugLn(e.Message); DebugLn(e.Message);
DumpExceptionBackTrace; DumpExceptionBackTrace;
@ -1168,7 +1164,8 @@ begin
{$ENDIF} {$ENDIF}
then begin then begin
Result:=Item.Translation; Result:=Item.Translation;
if Result='' then RaiseGDBException('TPOFile.Translate Inconsistency'); if Result='' then
Raise Exception.Create('TPOFile.Translate Inconsistency');
end else end else
Result:=OriginalValue; Result:=OriginalValue;
//Remove lineending at the end of the string if present. //Remove lineending at the end of the string if present.
@ -1211,7 +1208,7 @@ begin
DebugLn('Entries:'); DebugLn('Entries:');
DebugLn('---------------------------------------------'); DebugLn('---------------------------------------------');
for i:=0 to FItems.Count-1 do begin for i:=0 to FItems.Count-1 do begin
DebugLn('#',dbgs(i),': '); DebugLn(['#', i ,': ']);
Item := TPOFileItem(FItems[i]); Item := TPOFileItem(FItems[i]);
DebugLn('Comments=',Item.Comments); DebugLn('Comments=',Item.Comments);
DebugLn('Identifier=',Item.IdentifierLow); DebugLn('Identifier=',Item.IdentifierLow);
@ -1253,10 +1250,10 @@ begin
if (StopIndex > Count - 1) then StopIndex := Count - 1; if (StopIndex > Count - 1) then StopIndex := Count - 1;
if (StartIndex < 0) then StartIndex := 0; if (StartIndex < 0) then StartIndex := 0;
DebugLn('Entries [',DbgS(StartIndex),'..',Dbgs(StopIndex),']:'); DebugLn(['Entries [', StartIndex, '..', StopIndex, ']:']);
DebugLn('---------------------------------------------'); DebugLn('---------------------------------------------');
for i := StartIndex to StopIndex do begin for i := StartIndex to StopIndex do begin
DebugLn('#',dbgs(i),': '); DebugLn(['#', i, ': ']);
Item := TPOFileItem(FItems[i]); Item := TPOFileItem(FItems[i]);
DebugLn('Identifier=',Item.IdentifierLow); DebugLn('Identifier=',Item.IdentifierLow);
DebugLn('msgid=',Item.Original); DebugLn('msgid=',Item.Original);
@ -1297,10 +1294,10 @@ begin
if (StopIndex > Count - 1) then StopIndex := Count - 1; if (StopIndex > Count - 1) then StopIndex := Count - 1;
if (StartIndex < 0) then StartIndex := 0; if (StartIndex < 0) then StartIndex := 0;
Log.Add('Entries ['+DbgS(StartIndex)+'..'+Dbgs(StopIndex)+']:'); Log.Add(Format('Entries [%d..%d]:', [StartIndex, StopIndex]));
Log.Add('---------------------------------------------'); Log.Add('---------------------------------------------');
for i := StartIndex to StopIndex do begin for i := StartIndex to StopIndex do begin
Log.Add('#'+dbgs(i)+': '); Log.Add(Format('#%d: ', [i]));
Item := TPOFileItem(FItems[i]); Item := TPOFileItem(FItems[i]);
Log.Add('Identifier='+Item.IdentifierLow); Log.Add('Identifier='+Item.IdentifierLow);
Log.Add('msgid='+Item.Original); Log.Add('msgid='+Item.Original);
@ -1819,18 +1816,14 @@ var
begin begin
F := TStringList.Create; F := TStringList.Create;
try try
F.CommaText := Flags; F.CommaText := Flags;
i := F.IndexOf(AFlag); i := F.IndexOf(AFlag);
if (i<0) and Check then if (i<0) and Check then
F.Add(AFlag) F.Add(AFlag)
else else
if (i>=0) and (not Check) then if (i>=0) and (not Check) then
F.Delete(i); F.Delete(i);
Flags := F.CommaText; Flags := F.CommaText;
finally finally
F.Free; F.Free;
end; end;

View File

@ -17,13 +17,13 @@ uses
LCLStrConsts, LCLType, Menus, LCLUnicodeData, LCLVersion, LMessages, LCLStrConsts, LCLType, Menus, LCLUnicodeData, LCLVersion, LMessages,
LResources, MaskEdit, PairSplitter, PopupNotifier, PostScriptCanvas, LResources, MaskEdit, PairSplitter, PopupNotifier, PostScriptCanvas,
PostScriptPrinter, PostScriptUnicode, Printers, PropertyStorage, RubberBand, PostScriptPrinter, PostScriptUnicode, Printers, PropertyStorage, RubberBand,
ShellCtrls, Spin, StdActns, StdCtrls, Themes, TmSchema, Toolwin, ShellCtrls, Spin, StdActns, StdCtrls, Themes, TmSchema, Toolwin, UTrace,
Translations, UTrace, XMLPropStorage, TimePopup, Messages, WSButtons, XMLPropStorage, TimePopup, Messages, WSButtons, WSCalendar, WSCheckLst,
WSCalendar, WSCheckLst, WSComCtrls, WSControls, WSDesigner, WSDialogs, WSComCtrls, WSControls, WSDesigner, WSDialogs, WSExtCtrls, WSExtDlgs,
WSExtCtrls, WSExtDlgs, WSFactory, WSForms, WSGrids, WSImgList, WSLCLClasses, WSFactory, WSForms, WSGrids, WSImgList, WSLCLClasses, WSMenus,
WSMenus, WSPairSplitter, WSProc, WSReferences, WSSpin, WSStdCtrls, WSPairSplitter, WSProc, WSReferences, WSSpin, WSStdCtrls, WSToolwin,
WSToolwin, ActnList, AsyncProcess, ButtonPanel, Buttons, Calendar, ActnList, AsyncProcess, ButtonPanel, Buttons, Calendar, RegisterLCL,
RegisterLCL, ValEdit, LazCanvas, LazDialogs, LazRegions, CustomDrawn_Common, ValEdit, LazCanvas, LazDialogs, LazRegions, CustomDrawn_Common,
CustomDrawnControls, CustomDrawnDrawers, LazDeviceApis, LDockTree, CustomDrawnControls, CustomDrawnDrawers, LazDeviceApis, LDockTree,
LazFreeTypeIntfDrawer, CustomDrawn_WinXP, CustomDrawn_Android, Arrow, LazFreeTypeIntfDrawer, CustomDrawn_WinXP, CustomDrawn_Android, Arrow,
EditBtn, ComboEx, DBExtCtrls, CustomDrawn_Mac, CalcForm, LCLTranslator, EditBtn, ComboEx, DBExtCtrls, CustomDrawn_Mac, CalcForm, LCLTranslator,

File diff suppressed because it is too large Load Diff