Skip to content
Permalink
Browse files

Let TExtForm translate all strings on a form, to reduce the code in a…

…ny FormCreate event
  • Loading branch information...
ansgarbecker committed Jul 21, 2019
1 parent 88a9e53 commit fcdf32308682c051b8e9a5858fd2bcfd47da9928
@@ -45,6 +45,7 @@ uses
change_password in '..\..\source\change_password.pas' {frmPasswordChange},
Vcl.Themes,
Vcl.Styles,
Vcl.Graphics,
theme_preview in '..\..\source\theme_preview.pas' {frmThemePreview};

{.$R *.RES}
@@ -71,10 +72,15 @@ begin
AppSettings.Free;
Application.Terminate;
end else begin

AppLanguage := AppSettings.ReadString(asAppLanguage);
// SysLanguage may be zh_CN, while we don't offer such a language, but anyway, this is just the current system language:
SysLanguage := DefaultInstance.GetCurrentLocaleName;
UseLanguage(AppLanguage);
// First time translation via dxgettext.
// Issue #3064: Ignore TFont, so "Default" on mainform for WinXP users does not get broken.
TP_GlobalIgnoreClass(TFont);

Application.Initialize;
Application.Title := APPNAME;
Application.UpdateFormatSettings := False;
@@ -124,7 +124,6 @@ procedure TAboutBox.editDonatedExit(Sender: TObject);

procedure TAboutBox.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
lblAppName.Font.Size := Round(lblAppName.Font.Size * 1.5);
lblAppName.Font.Style := [fsBold];
lblAppWebpage.Font.Color := clBlue;
@@ -89,7 +89,6 @@ procedure TfrmBinEditor.SetFont(font: TFont);

procedure TfrmBinEditor.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
HasSizeGrip := True;
end;

@@ -57,7 +57,6 @@ implementation

procedure TfrmPasswordChange.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
HasSizeGrip := True;
end;

@@ -45,7 +45,6 @@ implementation

procedure TColumnSelectionForm.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
HasSizeGrip := True;
Width := AppSettings.ReadInt(asColumnSelectorWidth);
Height := AppSettings.ReadInt(asColumnSelectorHeight);
@@ -239,7 +239,6 @@ procedure Tconnform.FormCreate(Sender: TObject);
LibPath, LibFile: String;
begin
// Fix GUI stuff
TranslateComponent(Self);
HasSizeGrip := True;
FixDropDownButtons(Self);
lblDownloadPlink.Font.Style := [fsUnderline];
@@ -67,7 +67,6 @@ implementation

procedure TCopyTableForm.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
HasSizeGrip := True;
FixDropDownButtons(Self);
Width := AppSettings.ReadInt(asCopyTableWindowWidth);
@@ -41,7 +41,6 @@ implementation

procedure TCreateDatabaseForm.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
lblCreateCode.Caption := lblCreateCode.Caption + ':';
// Setup SynMemoPreview
SynMemoCreateCode.Highlighter := Mainform.SynSQLSynUsed;
@@ -47,8 +47,6 @@ procedure TDataSortingForm.FormCreate(Sender: TObject);
var
i: Integer;
begin
TranslateComponent(Self);

ColumnNames := TStringList.Create;
// Take column names from listColumns and add here
for i:=0 to Mainform.SelectedTableColumns.Count-1 do begin
@@ -55,7 +55,6 @@ implementation

procedure TfrmEditVariable.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
HasSizeGrip := True;
Width := AppSettings.ReadInt(asEditVarWindowWidth);
Height := AppSettings.ReadInt(asEditVarWindowHeight);
@@ -103,7 +103,6 @@ procedure TfrmExportGrid.FormCreate(Sender: TObject);
var
FormatDesc: String;
begin
TranslateComponent(Self);
HasSizeGrip := True;
Width := AppSettings.ReadInt(asGridExportWindowWidth);
Height := AppSettings.ReadInt(asGridExportWindowHeight);
@@ -4,7 +4,7 @@ interface

uses
Classes, SysUtils, Forms, Windows, Messages, System.Types, StdCtrls, Clipbrd,
SizeGrip, apphelpers, Vcl.Graphics, Vcl.Dialogs;
SizeGrip, apphelpers, Vcl.Graphics, Vcl.Dialogs, gnugettext;

type
// Form with a sizegrip in the lower right corner, without the need for a statusbar
@@ -36,6 +36,7 @@ constructor TExtForm.Create(AOwner: TComponent);
inherited;
InheritFont(Font);
HasSizeGrip := False;
TranslateComponent(Self);
end;


@@ -116,7 +116,6 @@ implementation

procedure TfrmInsertFiles.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
HasSizeGrip := True;
ListFiles.Images := GetSystemImageList;
DragAcceptFiles(Handle, True);
@@ -93,7 +93,6 @@ implementation

procedure Tloaddataform.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
HasSizeGrip := True;
// Restore settings
Width := AppSettings.ReadInt(asCSVImportWindowWidth);
@@ -36,7 +36,6 @@ implementation

procedure TfrmLogin.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
Caption := APPNAME + ' - Login';
MainForm.VirtualImageListMain.GetBitmap(144, imgIcon.Picture.Bitmap);
lblPrompt.Font.Size := 10;
@@ -1677,12 +1677,6 @@ procedure TMainForm.FormCreate(Sender: TObject);
begin
caption := APPNAME;

// First time translation via dxgettext.
// Issue #3064: Ignore TFont, so "Default" on mainform for WinXP users does not get broken.
// Issue #557: Apply images *after* translating main menu, so top items don't get unused
// space left besides them.
TP_GlobalIgnoreClass(TFont);
TranslateComponent(Self);
FixDropDownButtons(Self);

// Load preferred ImageCollection into VirtualImageList
@@ -483,7 +483,6 @@ procedure Toptionsform.FormCreate(Sender: TObject);
GridColorsPreset: TGridColorsPreset;
IconPack: String;
begin
TranslateComponent(Self);
HasSizeGrip := True;

Width := AppSettings.ReadInt(asPreferencesWindowWidth);
@@ -23,7 +23,6 @@ TprintlistForm = class(TForm)
procedure btnConfigureClick(Sender: TObject);
procedure btnPrintClick(Sender: TObject);
procedure comboPrintersChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
@@ -39,11 +38,6 @@ implementation
{$R *.DFM}


procedure TprintlistForm.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
end;

procedure TprintlistForm.FormShow(Sender: TObject);
begin
// show!
@@ -59,7 +59,6 @@ implementation

procedure TfrmSearchReplace.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
HasSizeGrip := True;
comboSearch.Items.Text := AppSettings.ReadString(asFindDialogSearchHistory);
comboReplace.Items.Text := AppSettings.ReadString(asFindDialogReplaceHistory);
@@ -62,7 +62,6 @@ function SelectDBObjects: TDBObjectList;

procedure TfrmSelectDBObject.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
HasSizeGrip := True;
Width := AppSettings.ReadInt(asSelectDBOWindowWidth);
Height := AppSettings.ReadInt(asSelectDBOWindowHeight);
@@ -93,7 +93,6 @@ procedure TfrmSQLhelp.FormCreate(Sender: TObject);
memoDescription.Height := AppSettings.ReadInt(asSQLHelpPnlRightTopHeight);
Caption := DEFAULT_WINDOW_CAPTION;
FixVT(treeTopics);
TranslateComponent(Self);
HasSizeGrip := True;

treeTopics.Clear;
@@ -107,7 +107,6 @@ procedure TfrmSyncDB.FormCreate(Sender: TObject);
SessionPaths: TStringList;
begin
Caption := MainForm.actSynchronizeDatabase.Caption;
TranslateComponent(Self);
HasSizeGrip := True;
FixVT(treeSource);
FixVT(treeDifferences);
@@ -225,7 +225,6 @@ procedure TfrmTableTools.FormCreate(Sender: TObject);
dt: TListNodeType;
Obj: TDBObject;
begin
TranslateComponent(Self);
HasSizeGrip := True;
FixDropDownButtons(Self);
OUTPUT_FILE := _('Single .sql file');
@@ -202,7 +202,6 @@ procedure TfrmTextEditor.FormCreate(Sender: TObject);
actSearchFindNext.Hint := MainForm.actQueryFindAgain.Hint;
actSearchReplace.Caption := MainForm.actQueryReplace.Caption;
actSearchReplace.Hint := MainForm.actQueryReplace.Hint;
TranslateComponent(Self);
FixDropDownButtons(Self);
// Assign linebreak values to their menu item tags, to write less code later
menuWindowsLB.Tag := Integer(lbsWindows);
@@ -51,7 +51,6 @@ implementation
procedure TfrmUpdateCheck.FormCreate(Sender: TObject);
begin
// Should be false by default. Callers can set this to True after Create()
TranslateComponent(Self);
imgDonate.OnClick := MainForm.DonateClick;
imgDonate.Visible := MainForm.HasDonated(False) = nbFalse;
end;
@@ -215,7 +215,6 @@ procedure TUserManagerForm.FormCreate(Sender: TObject);
FixVT(listUsers);
FixVT(treePrivs);
Mainform.RestoreListSetup(listUsers);
TranslateComponent(Self);
PrivsRead := Explode(',', 'SELECT,SHOW VIEW,SHOW DATABASES,PROCESS,EXECUTE');
PrivsWrite := Explode(',', 'ALTER,CREATE,DROP,DELETE,UPDATE,INSERT,ALTER ROUTINE,CREATE ROUTINE,CREATE TEMPORARY TABLES,CREATE VIEW,INDEX,TRIGGER,EVENT,REFERENCES,CREATE TABLESPACE');
PrivsAdmin := Explode(',', 'RELOAD,SHUTDOWN,REPLICATION CLIENT,REPLICATION SLAVE,SUPER,LOCK TABLES,GRANT,FILE,CREATE USER');

0 comments on commit fcdf323

Please sign in to comment.
You can’t perform that action at this time.