From fcdf32308682c051b8e9a5858fd2bcfd47da9928 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 21 Jul 2019 20:12:13 +0200 Subject: [PATCH] Let TExtForm translate all strings on a form, to reduce the code in any FormCreate event --- packages/Delphi10.3/heidisql.dpr | 6 ++++++ source/about.pas | 1 - source/bineditor.pas | 1 - source/change_password.pas | 1 - source/column_selection.pas | 1 - source/connections.pas | 1 - source/copytable.pas | 1 - source/createdatabase.pas | 1 - source/data_sorting.pas | 2 -- source/editvar.pas | 1 - source/exportgrid.pas | 1 - source/extra_controls.pas | 3 ++- source/insertfiles.pas | 1 - source/loaddata.pas | 1 - source/loginform.pas | 1 - source/main.pas | 6 ------ source/options.pas | 1 - source/printlist.pas | 6 ------ source/searchreplace.pas | 1 - source/selectdbobject.pas | 1 - source/sqlhelp.pas | 1 - source/syncdb.pas | 1 - source/tabletools.pas | 1 - source/texteditor.pas | 1 - source/updatecheck.pas | 1 - source/usermanager.pas | 1 - 26 files changed, 8 insertions(+), 36 deletions(-) diff --git a/packages/Delphi10.3/heidisql.dpr b/packages/Delphi10.3/heidisql.dpr index 8ebc79b6..7d9e0ff6 100644 --- a/packages/Delphi10.3/heidisql.dpr +++ b/packages/Delphi10.3/heidisql.dpr @@ -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; diff --git a/source/about.pas b/source/about.pas index dd36fdb1..780c3bcf 100644 --- a/source/about.pas +++ b/source/about.pas @@ -124,7 +124,6 @@ end; 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; diff --git a/source/bineditor.pas b/source/bineditor.pas index 04ccdfb4..ae0ff46e 100644 --- a/source/bineditor.pas +++ b/source/bineditor.pas @@ -89,7 +89,6 @@ end; procedure TfrmBinEditor.FormCreate(Sender: TObject); begin - TranslateComponent(Self); HasSizeGrip := True; end; diff --git a/source/change_password.pas b/source/change_password.pas index 3838c594..49b79750 100644 --- a/source/change_password.pas +++ b/source/change_password.pas @@ -57,7 +57,6 @@ uses main, apphelpers; procedure TfrmPasswordChange.FormCreate(Sender: TObject); begin - TranslateComponent(Self); HasSizeGrip := True; end; diff --git a/source/column_selection.pas b/source/column_selection.pas index 08ddca70..eb6c92ad 100644 --- a/source/column_selection.pas +++ b/source/column_selection.pas @@ -45,7 +45,6 @@ uses main; procedure TColumnSelectionForm.FormCreate(Sender: TObject); begin - TranslateComponent(Self); HasSizeGrip := True; Width := AppSettings.ReadInt(asColumnSelectorWidth); Height := AppSettings.ReadInt(asColumnSelectorHeight); diff --git a/source/connections.pas b/source/connections.pas index 05ef3fde..611ffb34 100644 --- a/source/connections.pas +++ b/source/connections.pas @@ -239,7 +239,6 @@ var LibPath, LibFile: String; begin // Fix GUI stuff - TranslateComponent(Self); HasSizeGrip := True; FixDropDownButtons(Self); lblDownloadPlink.Font.Style := [fsUnderline]; diff --git a/source/copytable.pas b/source/copytable.pas index 2cb15348..70365cc8 100644 --- a/source/copytable.pas +++ b/source/copytable.pas @@ -67,7 +67,6 @@ const procedure TCopyTableForm.FormCreate(Sender: TObject); begin - TranslateComponent(Self); HasSizeGrip := True; FixDropDownButtons(Self); Width := AppSettings.ReadInt(asCopyTableWindowWidth); diff --git a/source/createdatabase.pas b/source/createdatabase.pas index 3b98234a..55b72c7f 100644 --- a/source/createdatabase.pas +++ b/source/createdatabase.pas @@ -41,7 +41,6 @@ uses main, apphelpers; procedure TCreateDatabaseForm.FormCreate(Sender: TObject); begin - TranslateComponent(Self); lblCreateCode.Caption := lblCreateCode.Caption + ':'; // Setup SynMemoPreview SynMemoCreateCode.Highlighter := Mainform.SynSQLSynUsed; diff --git a/source/data_sorting.pas b/source/data_sorting.pas index 649b807e..77dcc9ae 100644 --- a/source/data_sorting.pas +++ b/source/data_sorting.pas @@ -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 diff --git a/source/editvar.pas b/source/editvar.pas index 19c1eb26..3c0211f3 100644 --- a/source/editvar.pas +++ b/source/editvar.pas @@ -55,7 +55,6 @@ uses main, apphelpers; procedure TfrmEditVariable.FormCreate(Sender: TObject); begin - TranslateComponent(Self); HasSizeGrip := True; Width := AppSettings.ReadInt(asEditVarWindowWidth); Height := AppSettings.ReadInt(asEditVarWindowHeight); diff --git a/source/exportgrid.pas b/source/exportgrid.pas index 8dfada8b..fe4be8a1 100644 --- a/source/exportgrid.pas +++ b/source/exportgrid.pas @@ -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); diff --git a/source/extra_controls.pas b/source/extra_controls.pas index eda5ca86..297db8fd 100644 --- a/source/extra_controls.pas +++ b/source/extra_controls.pas @@ -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 @@ begin inherited; InheritFont(Font); HasSizeGrip := False; + TranslateComponent(Self); end; diff --git a/source/insertfiles.pas b/source/insertfiles.pas index 5a9c2323..065b069a 100644 --- a/source/insertfiles.pas +++ b/source/insertfiles.pas @@ -116,7 +116,6 @@ const procedure TfrmInsertFiles.FormCreate(Sender: TObject); begin - TranslateComponent(Self); HasSizeGrip := True; ListFiles.Images := GetSystemImageList; DragAcceptFiles(Handle, True); diff --git a/source/loaddata.pas b/source/loaddata.pas index c6e1cbd0..89816c8c 100644 --- a/source/loaddata.pas +++ b/source/loaddata.pas @@ -93,7 +93,6 @@ const procedure Tloaddataform.FormCreate(Sender: TObject); begin - TranslateComponent(Self); HasSizeGrip := True; // Restore settings Width := AppSettings.ReadInt(asCSVImportWindowWidth); diff --git a/source/loginform.pas b/source/loginform.pas index 2987db0e..079a22f2 100644 --- a/source/loginform.pas +++ b/source/loginform.pas @@ -36,7 +36,6 @@ uses apphelpers, main; procedure TfrmLogin.FormCreate(Sender: TObject); begin - TranslateComponent(Self); Caption := APPNAME + ' - Login'; MainForm.VirtualImageListMain.GetBitmap(144, imgIcon.Picture.Bitmap); lblPrompt.Font.Size := 10; diff --git a/source/main.pas b/source/main.pas index aaa8377a..add63c6f 100644 --- a/source/main.pas +++ b/source/main.pas @@ -1677,12 +1677,6 @@ var 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 diff --git a/source/options.pas b/source/options.pas index 4bad43da..cd4ef5dc 100644 --- a/source/options.pas +++ b/source/options.pas @@ -483,7 +483,6 @@ var GridColorsPreset: TGridColorsPreset; IconPack: String; begin - TranslateComponent(Self); HasSizeGrip := True; Width := AppSettings.ReadInt(asPreferencesWindowWidth); diff --git a/source/printlist.pas b/source/printlist.pas index 3574818c..0df1b8cd 100644 --- a/source/printlist.pas +++ b/source/printlist.pas @@ -23,7 +23,6 @@ type 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 @@ uses main, apphelpers, table_editor, dbconnection; {$R *.DFM} -procedure TprintlistForm.FormCreate(Sender: TObject); -begin - TranslateComponent(Self); -end; - procedure TprintlistForm.FormShow(Sender: TObject); begin // show! diff --git a/source/searchreplace.pas b/source/searchreplace.pas index ea0ae1b4..20820170 100644 --- a/source/searchreplace.pas +++ b/source/searchreplace.pas @@ -59,7 +59,6 @@ uses apphelpers, main; procedure TfrmSearchReplace.FormCreate(Sender: TObject); begin - TranslateComponent(Self); HasSizeGrip := True; comboSearch.Items.Text := AppSettings.ReadString(asFindDialogSearchHistory); comboReplace.Items.Text := AppSettings.ReadString(asFindDialogReplaceHistory); diff --git a/source/selectdbobject.pas b/source/selectdbobject.pas index 258d101d..66a1871c 100644 --- a/source/selectdbobject.pas +++ b/source/selectdbobject.pas @@ -62,7 +62,6 @@ end; procedure TfrmSelectDBObject.FormCreate(Sender: TObject); begin - TranslateComponent(Self); HasSizeGrip := True; Width := AppSettings.ReadInt(asSelectDBOWindowWidth); Height := AppSettings.ReadInt(asSelectDBOWindowHeight); diff --git a/source/sqlhelp.pas b/source/sqlhelp.pas index b38f437c..3c58fd6f 100644 --- a/source/sqlhelp.pas +++ b/source/sqlhelp.pas @@ -93,7 +93,6 @@ begin memoDescription.Height := AppSettings.ReadInt(asSQLHelpPnlRightTopHeight); Caption := DEFAULT_WINDOW_CAPTION; FixVT(treeTopics); - TranslateComponent(Self); HasSizeGrip := True; treeTopics.Clear; diff --git a/source/syncdb.pas b/source/syncdb.pas index e4160532..ddcf4bd6 100644 --- a/source/syncdb.pas +++ b/source/syncdb.pas @@ -107,7 +107,6 @@ var SessionPaths: TStringList; begin Caption := MainForm.actSynchronizeDatabase.Caption; - TranslateComponent(Self); HasSizeGrip := True; FixVT(treeSource); FixVT(treeDifferences); diff --git a/source/tabletools.pas b/source/tabletools.pas index bc05dc11..d23838c3 100644 --- a/source/tabletools.pas +++ b/source/tabletools.pas @@ -225,7 +225,6 @@ var dt: TListNodeType; Obj: TDBObject; begin - TranslateComponent(Self); HasSizeGrip := True; FixDropDownButtons(Self); OUTPUT_FILE := _('Single .sql file'); diff --git a/source/texteditor.pas b/source/texteditor.pas index 20207c42..e07bc9b5 100644 --- a/source/texteditor.pas +++ b/source/texteditor.pas @@ -202,7 +202,6 @@ begin 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); diff --git a/source/updatecheck.pas b/source/updatecheck.pas index e486549a..05847749 100644 --- a/source/updatecheck.pas +++ b/source/updatecheck.pas @@ -51,7 +51,6 @@ uses main; 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; diff --git a/source/usermanager.pas b/source/usermanager.pas index fedeff6b..62ac3dca 100644 --- a/source/usermanager.pas +++ b/source/usermanager.pas @@ -215,7 +215,6 @@ begin 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');