Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added localization #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Source/Core/ormbr.bind.pas
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ procedure TBind.SetPropertyToField(const AObject: TObject;
end;
except
on E: Exception do
raise Exception.Create('Column : ' + LColumn.ColumnName
raise Exception.Create(SColumn + LColumn.ColumnName
+ sLineBreak
+ E.Message);
end;
Expand Down Expand Up @@ -494,7 +494,7 @@ procedure TBind.SetDataDictionary(const ADataSet: TDataSet;
raise Exception.Create('ormbr.bind->SetDataDictionary()'
+ sLineBreak
+ sLineBreak
+ 'Column: ' + LFieldName);
+ SColumn + LFieldName);
end;
end;
end;
Expand Down Expand Up @@ -707,7 +707,7 @@ procedure TBind.SetFieldToProperty(const ADataSet: IDBResultSet;
_SetFieldToProperty(ADataSet.GetField(LColumn.ColumnName), LColumn, AObject);
except
on E: Exception do
raise Exception.Create('Problem when binding column "' +
raise Exception.Create(SProblemBindingColumn +
LColumn.ColumnName + '" - ' + E.Message);
end;
end;
Expand Down Expand Up @@ -788,7 +788,7 @@ procedure TBind.SetFieldToProperty(const ADataSet: TDataSet;
_SetFieldToProperty(ADataSet.FieldByName(LColumn.ColumnName), LColumn, AObject);
except
on E: Exception do
raise Exception.CreateFmt('Problem when binding [%s->%s] (message: %s)',
raise Exception.CreateFmt(SProblemBinding,
[ADataSet.Name, LColumn.ColumnName, E.Message]);
end;
end;
Expand Down Expand Up @@ -858,7 +858,7 @@ procedure TBind._SetFieldToPropertyRecord(const LProperty: TRttiProperty;
end;
end
else
raise Exception.CreateFmt('Column [%s] must have blob value', [AColumn.ColumnName]);
raise Exception.CreateFmt(SColumnMustHaveBlobValue, [AColumn.ColumnName]);
end
else
LProperty.SetValueNullable(AObject, LProperty.PropertyType.Handle, AField.Value, False);
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/ormbr.command.executor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ implementation
ormbr.bind,
ormbr.session.abstract,
ormbr.objects.helper,
ormbr.rtti.helper;
ormbr.rtti.helper,
ormbr.core.consts;

{ TObjectManager<M> }

Expand All @@ -121,7 +122,7 @@ constructor TSQLCommandExecutor<M>.Create(const AOwner: TObject;
FPageSize := APageSize;
if not (AOwner is TSessionAbstract<M>) then
raise Exception
.Create('O Object Manager n�o deve ser inst�nciada diretamente, use as classes TSessionObject<M> ou TSessionDataSet<M>');
.Create(SObjectManagerNotDirectCreate);
FConnection := AConnection;

FObjectInternal := M.Create;
Expand Down
46 changes: 46 additions & 0 deletions Source/Core/ormbr.core.consts.pas
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

interface

{$INCLUDE ..\ormbr.inc}

uses
TypInfo;

Expand All @@ -48,7 +50,51 @@ interface
tkPointer,
tkProcedure];

resourcestring
{$IFDEF CBLIB_BR}
SColumn = 'Column : ';
SProblemBindingColumn = 'Problem when binding column "';
SProblemBinding = 'Problem when binding [%s->%s] (message: %s)';
SColumnMustHaveBlobValue = 'Column [%s] must have blob value';
SObjectManagerNotDirectCreate = 'O Object Manager n�o deve ser inst�nciada diretamente, use as classes TSessionObject<M> ou TSessionDataSet<M>';
SDriver = 'O Driver ';
SDNotRegister = ' n�o est� registrado, adicione a unit "ormbr.dml.generator.???.pas" onde ??? nome do driver, na cl�usula USES do seu projeto!';
SPropertyError = 'Erro no SetValue() da propriedade ';
SCannotFindMetod = 'Cannot find method "%s" in the object';
SCannotFindConstructor = 'Cannot find a property constructor for ';
SInvalidImage = 'Invalid image';
SCannotAssign = 'Cannot assigned non-null pointer to nullable type.';
{$ENDIF}

{$IFDEF CBLIB_EN}
SColumn = 'Column : ';
SProblemBindingColumn = 'Problem when binding column "';
SProblemBinding = 'Problem when binding [%s->%s] (message: %s)';
SColumnMustHaveBlobValue = 'Column [%s] must have blob value';
SObjectManagerNotDirectCreate = 'The Object Manager must not be instantiated directly, use the classes TSessionObject<M> or TSessionDataSet<M>';
SDriver = 'The Driver ';
SDNotRegister = ' is not registered, add the unit "ormbr.dml.generator.???.pas" where ??? driver name, in the USES clause of your project!';
SPropertyError = 'Error in SetValue() of property ';
SCannotFindMetod = 'Cannot find method "%s" in the object';
SCannotFindConstructor = 'Cannot find a property constructor for ';
SInvalidImage = 'Invalid image';
SCannotAssign = 'Cannot assigned non-null pointer to nullable type.';
{$ENDIF}

{$IFDEF CBLIB_RU}
SColumn = '������� : ';
SProblemBindingColumn = '�������� ��� �������� ������� "';
SProblemBinding = '�������� ��� �������� [%s->%s] (���������: %s)';
SColumnMustHaveBlobValue = '������� [%s] ������ ����� �������� blob';
SObjectManagerNotDirectCreate = '��������� �������� �� ������ ����������� ��������, ����������� ������ TSessionObject<M> ��� TSessionDataSet<M>';
SDriver = '������� ';
SDNotRegister = ' �� ���������������, �������� ������ "ormbr.dml.generator.???.pas" ��� ??? ��� �������� � ������� USES ������ �������!';
SPropertyError = '������ � �������� SetValue() ';
SCannotFindMetod = 'Cannot find method "%s" in the object';
SCannotFindConstructor = '���������� ����� ����������� ������� ��� ';
SInvalidImage = '������������ �����������';
SCannotAssign = '���������� ��������� ��������� ��������� nullable ����.';
{$ENDIF}
implementation

end.
3 changes: 2 additions & 1 deletion Source/Core/ormbr.driver.register.pas
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface
SysUtils,
Generics.Collections,
ormbr.dml.interfaces,
ormbr.core.consts,
dbebr.factory.interfaces;

type
Expand Down Expand Up @@ -65,7 +66,7 @@ class function TDriverRegister.GetDriver(const ADriverName: TDriverName): IDMLGe
begin
if not FDriver.ContainsKey(ADriverName) then
raise Exception
.Create('O driver ' + TStrDriverName[ADriverName] + ' n�o est� registrado, adicione a unit "ormbr.dml.generator.???.pas" onde ??? nome do driver, na cl�usula USES do seu projeto!');
.Create(SDriver + TStrDriverName[ADriverName] + SDNotRegister);

Result := FDriver[ADriverName];
end;
Expand Down
7 changes: 4 additions & 3 deletions Source/Core/ormbr.json.pas
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ TORMBrJson = class
implementation

uses
ormbr.rtti.helper;
ormbr.rtti.helper,
ormbr.core.consts;

{ TJson }

Expand Down Expand Up @@ -172,7 +173,7 @@ class procedure TORMBrJson.DoGetValue({const Sender: TJSONBrObject;}
end;
except
on E: Exception do
raise Exception.Create('Erro no SetValue() da propriedade [' + AProperty.Name + ']' + sLineBreak + E.Message);
raise Exception.Create(SPropertyError + '[' + AProperty.Name + ']' + sLineBreak + E.Message);
end;
end;

Expand Down Expand Up @@ -228,7 +229,7 @@ class procedure TORMBrJson.DoSetValue(const AInstance: TObject;
end;
except
on E: Exception do
raise Exception.Create('Erro no SetValue() da propriedade [' + AProperty.Name + ']' + sLineBreak + E.Message);
raise Exception.Create(SPropertyError + '[' + AProperty.Name + ']' + sLineBreak + E.Message);
end;
end;
end;
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/ormbr.objects.helper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ TObjectHelper = class helper for TObject
end;

implementation

uses
ormbr.core.consts;
{ TObjectHelper }

function TObjectHelper.GetNotServerUse: NotServerUse;
Expand Down Expand Up @@ -185,7 +186,7 @@ function TObjectHelper.MethodCall(const AMethodName: String;
if Assigned(LMethod) then
Result := LMethod.Invoke(Self, AParameters)
else
raise Exception.CreateFmt('Cannot find method "%s" in the object', [AMethodName]);
raise Exception.CreateFmt(SCannotFindMetod, [AMethodName]);
finally
LContext.Free;
end;
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/ormbr.objects.utils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ implementation
uses
dbcbr.mapping.explorer,
dbcbr.rtti.helper,
ormbr.objects.helper;
ormbr.objects.helper,
ormbr.core.consts;

function RttiSingleton: IRttiSingleton;
begin
Expand Down Expand Up @@ -286,7 +287,7 @@ function TRttiSingleton.CreateObject(ARttiType: TRttiType): TObject;
if Assigned(metaClass) then
Result := Method.Invoke(metaClass, []).AsObject
else
raise Exception.Create('Cannot find a propert constructor for ' + ARttiType.ToString);
raise Exception.Create(SCannotFindConstructor + ARttiType.ToString);
end;

function TRttiSingleton.GetRttiType(AClass: TClass): TRttiType;
Expand Down
8 changes: 5 additions & 3 deletions Source/Core/ormbr.types.blob.pas
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ TBlob = record

implementation

uses
ormbr.core.consts;
const
MinGraphicSize = 44;

Expand All @@ -109,7 +111,7 @@ procedure TBlob.SetBlobField(const Value: TBlobField; const ACompression: Boolea
BuildBlobFieldToStream(ACompression);
end
else
raise Exception.Create(Format('Column [%s] must have blob value', [Value.FieldName]));
raise Exception.Create(Format(SColumnMustHaveBlobValue, [Value.FieldName]));
end;

procedure TBlob.SetBytes(const Value: TBytes);
Expand Down Expand Up @@ -198,7 +200,7 @@ procedure TBlob.ToPicture(APicture: TPicture; const ACompression: Boolean);
try
DecompressStream(LSourceStream, LTargetStream);
if not FindGraphicClass(LTargetStream.Memory^, LTargetStream.Size, LGraphicClass) then
raise EInvalidGraphic.Create('Invalid image');
raise EInvalidGraphic.Create(SInvalidImage);
LGraphic := LGraphicClass.Create;
LTargetStream.Position := 0;
LGraphic.LoadFromStream(LTargetStream);
Expand All @@ -209,7 +211,7 @@ procedure TBlob.ToPicture(APicture: TPicture; const ACompression: Boolean);
else
begin
if not FindGraphicClass(LSourceStream.Memory^, LSourceStream.Size, LGraphicClass) then
raise EInvalidGraphic.Create('Invalid image');
raise EInvalidGraphic.Create(SInvalidImage);
LGraphic := LGraphicClass.Create;
LSourceStream.Position := 0;
LGraphic.LoadFromStream(LSourceStream);
Expand Down
5 changes: 4 additions & 1 deletion Source/Core/ormbr.types.nullable.pas
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ Nullable<T> = record

implementation

uses
ormbr.core.consts;

const
CHasValueFlag = '@';

Expand Down Expand Up @@ -190,7 +193,7 @@ function Nullable<T>.Equals(const other: Nullable<T>): Boolean;
if not Assigned(Value) then
Result.Clear
else
raise Exception.Create('Cannot assigned non-null pointer to nullable type.');
raise Exception.Create(SCannotAssign);
end;

class operator Nullable<T>.Equal(const a, b: Nullable<T>): Boolean;
Expand Down
4 changes: 3 additions & 1 deletion Source/Dataset/ormbr.container.clientdataset.pas
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ TContainerClientDataSet<M: class, constructor> = class(TContainerDataSet<M>)
end;

implementation
uses
ormbr.dataset.consts;

{ TContainerClientDataSet }

constructor TContainerClientDataSet<M>.Create(AConnection: IDBConnection;
ADataSet: TDataSet; APageSize: Integer; AMasterObject: TObject);
begin
if not (ADataSet is TClientDataSet) then
raise Exception.Create('Is not TClientDataSet type');
raise Exception.Create(SIsNotClientDatasetType);

FDataSetAdapter := TClientDataSetAdapter<M>.Create(AConnection, ADataSet, APageSize, AMasterObject)
end;
Expand Down
4 changes: 3 additions & 1 deletion Source/Dataset/ormbr.container.fdmemtable.pas
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ TContainerFDMemTable<M: class, constructor> = class(TContainerDataSet<M>)
end;

implementation
uses
ormbr.dataset.consts;

{ TContainerFDMemTable }

constructor TContainerFDMemTable<M>.Create(AConnection: IDBConnection;
ADataSet: TDataSet; APageSize: Integer; AMasterObject: TObject);
begin
if not (ADataSet is TFDMemTable) then
raise Exception.Create('Is not TFDMemTable type');
raise Exception.Create(SIsNotFDMemTableType);

FDataSetAdapter := TFDMemTableAdapter<M>.Create(AConnection, ADataSet, APageSize, AMasterObject)
end;
Expand Down
2 changes: 1 addition & 1 deletion Source/Dataset/ormbr.dataset.base.adapter.pas
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ procedure TDataSetBaseAdapter<M>._ExecuteOneToMany(AObject: M;
LPropertyType := AProperty.GetTypeValue(LPropertyType);
if not LPropertyType.IsInstance then
raise Exception
.Create('Not in instance ' + LPropertyType.Parent.ClassName + ' - '
.Create(SNotInInstance + LPropertyType.Parent.ClassName + ' - '
+ LPropertyType.Name);
//
if ADatasetBase.FCurrentInternal.ClassType <>
Expand Down
32 changes: 32 additions & 0 deletions Source/Dataset/ormbr.dataset.consts.pas
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,43 @@

interface

{$INCLUDE ..\ormbr.inc}

const
cFIELDEVENTS = '%s event required in column [%s]!';
cNOTFIELDTYPEBLOB = 'Column [%s] must have blob value';
cCREATEBINDDATASET = 'Access class %s by method %s';

resourcestring
{$IFDEF CBLIB_BR}
SIsNotClientDatasetType = 'Is not TClientDataSet type';
SIsNotFDMemTableType = 'Is not TFDMemTable type';
SNotInInstance = 'Not in instance ';
SCalculatedField 'O Campo calculado : ';
SExists = ' j� existe';
SAggregatedField = 'O Campo agregado de nome : ';
SEnableDirective = 'Enable the directive in file ormbr.inc : ';
{$ENDIF}

{$IFDEF CBLIB_EN}
SIsNotClientDatasetType = 'Is not TClientDataSet type';
SIsNotFDMemTableType = 'Is not TFDMemTable type';
SNotInInstance = 'Not in instance ';
SCalculatedField 'The Calculated Field: ';
SExists = ' already exist';
SAggregatedField = 'Aggregated field : ';
SEnableDirective = 'Enable the directive in file ormbr.inc : ';
{$ENDIF}

{$IFDEF CBLIB_RU}
SIsNotClientDatasetType = '�� �������� ����� TClientDataSet';
SIsNotFDMemTableType = '�� �������� ����� TFDMemTable';
SNotInInstance = 'Not in instance ';
SCalculatedField '����������� ���� : ';
SExists = ' ��� ����������';
SAggregatedField = '���������� ���� : ';
SEnableDirective = '�������� ��������� � ����� ormbr.inc : ';
{$ENDIF}
implementation

end.
6 changes: 4 additions & 2 deletions Source/Dataset/ormbr.dataset.fields.pas
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ TFieldSingleton = class(TInterfacedObject, IFieldSingleton)
end;

implementation
uses
ormbr.dataset.consts;

procedure TFieldSingleton.AddField(const ADataSet: TDataSet;
const AFieldName: String;
Expand Down Expand Up @@ -252,7 +254,7 @@ procedure TFieldSingleton.AddCalcField(const ADataSet: TDataSet;
LField: TField;
begin
if (ADataSet.FindField(AFieldName) <> nil) then
raise Exception.Create('O Campo calculado : ' + AFieldName + ' j� existe');
raise Exception.Create(SCalculatedField + AFieldName + SExists);

LField := GetFieldType(ADataSet, AFieldType);
if LField = nil then
Expand Down Expand Up @@ -281,7 +283,7 @@ procedure TFieldSingleton.AddAggregateField(const ADataSet: TDataSet;
LField: TAggregateField;
begin
if ADataSet.FindField(AFieldName) <> nil then
raise Exception.Create('O Campo agregado de nome : ' + AFieldName + ' j� existe');
raise Exception.Create(SAggregatedField + AFieldName + SExists);

LField := TAggregateField.Create(ADataSet);
if LField = nil then
Expand Down
Loading