Ignore:
Timestamp:
Feb 24, 2019, 5:24:45 AM (6 years ago)
Author:
ataylor
Message:

(ConfigApps) Implement NLS; fix icon rendering problem; tweak default mnemonics.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ConfigApps/MainFormUnit.pas

    r413 r414  
    44
    55Uses
    6   Classes, Forms, Graphics, StdCtrls, Buttons, MultiColumnListBox, Dialogs;
     6  Classes, Forms, Graphics, StdCtrls, Buttons, MultiColumnListBox, Dialogs, ACLLanguageUnit;
    77
    88const
    9   AppVersion = 'V1.1.1'; // $SS_REQUIRE_NEW_VERSION$
     9  AppVersion = 'V1.2.0'; // $SS_REQUIRE_NEW_VERSION$
    1010
    1111type
     
    3636    ParametersLabel: TLabel;
    3737    VersionLabel: TLabel;
     38    LngItems: String;
     39    LngPath: String;
     40    LngWebBrowser: String;
     41    LngEmail: String;
     42    LngNewsgroups: String;
     43    LngFtp: String;
     44    LngIrc: String;
     45    LngDiscardChanges: String;
     46    LngExitAndDiscardChanges: String;
     47    LngFileDoesNotExist: String;
     48    LngProgramNotFoundInPath: String;
     49    LngDirectoryDoesNotExist: String;
     50    LngSaveAnyway: String;
    3851    Procedure ParametersEditOnChange (Sender: TObject);
    3952    Procedure RestoreButtonOnClick (Sender: TObject);
     
    5265    Displaying: boolean;
    5366    Changed: boolean;
     67  Protected
     68    Procedure OnLanguageEvent( Language: TLanguageFile; const Apply: boolean );
    5469  Public
    5570    {Insert public declarations here}
     
    6984  ACLFileUtility, ACLUtility, ACLStringUtility,
    7085  ControlsUtility, ACLDialogs;
     86
     87{$R Images}
    7188
    7289type
     
    116133
    117134var
     135  ProgramNames: array[ Low( TProgramType ).. High( TProgramType ) ] of String = (
     136      'Web Browser', 'Email', 'Newsgroups', 'FTP', 'IRC'
     137  );
     138
    118139  CurrentSettings: array[ Low( TProgramType ).. High( TProgramType ) ] of TCurrentSettings;;
    119140
     
    178199Begin
    179200  if Changed then
    180     if not DoConfirmDlg( 'Discard changes?',
    181                          'Exit and discard changes?' ) then
     201    if not DoConfirmDlg( LngDiscardChanges,
     202                         LngExitAndDiscardChanges ) then
    182203      CanClose := false;
    183204
     
    211232          // they specified a path...
    212233          if not FileExists( Path ) then
    213             if not DoConfirmDlg( p.Name,
    214                                  'File does not exist: ' + EndLine
     234            if not DoConfirmDlg( ProgramNames[ ProgramType ],
     235                                 LngFileDoesNotExist + EndLine
    215236                                 + Path + EndLine
    216                                  + 'Save anyway?' ) then
     237                                 + LngSaveAnyway ) then
    217238              exit;
    218239        end
     
    223244                             Path,
    224245                             FoundPath ) then
    225             if not DoConfirmDlg( p.Name,
    226                                  'Program not found in path: ' + EndLine
     246            if not DoConfirmDlg( ProgramNames[ ProgramType ],
     247                                 LngProgramNotFoundInPath + EndLine
    227248                                 + Path + EndLine
    228                                  + 'Save anyway?' ) then
     249                                 + LngSaveAnyway ) then
    229250              exit;
    230251        end;
    231252        if not DirectoryExists( WorkingDirectory ) then
    232           if not DoConfirmDlg( p.Name,
    233                                'Directory does not exist: '
    234                                + WorkingDirectory
    235                                + '. Save anyway?' ) then
     253          if not DoConfirmDlg( ProgramNames[ ProgramType ],
     254                               LngDirectoryDoesNotExist + EndLine
     255                               + WorkingDirectory + EndLine
     256                               + LngSaveAnyway ) then
    236257            exit;
    237258      end;
     
    292313  for i := 0 to ItemsListBox.Items.Count - 1 do
    293314    if TProgramType( ItemsListBox.Items.Objects[ i ] ) = p then
    294       ItemsListBox.Items[ i ] := Programs[ p ].Name
     315      ItemsListBox.Items[ i ] := ProgramNames[ p ]
    295316                                 + #9
    296317                                 + PathEdit.Text;
     
    318339  Font := GetNiceDefaultFont;
    319340
     341  Forms.FormIconResourceID := 1;
     342
     343  RegisterForLanguages( OnLanguageEvent );
     344
    320345  VersionLabel.Caption := AppVersion;
     346  LoadDefaultLanguage('cfgapps');
    321347  LoadCurrentSettings;
     348
    322349end;
    323350
     
    335362    CurrentSettings[ ProgramType ].Parameters := GetParameters( p );
    336363
    337     ItemsListBox.Items.AddObject( P.Name
     364    ItemsListBox.Items.AddObject( ProgramNames[ ProgramType ]
    338365                                  + #9
    339366                                  + CurrentSettings[ ProgramType ].Path,
     
    347374End;
    348375
     376Procedure TMainForm.OnLanguageEvent( Language: TLanguageFile;
     377                                     const Apply: boolean );
     378Var
     379  ProgramType: TProgramType;
     380  P: TProgramSettings;
     381Begin
     382  Language.LoadComponentLanguage( self, Apply );
     383
     384  Language.LL( Apply, LngWebBrowser, 'ProgramWebBrowser', 'Web Browser' );
     385  Language.LL( Apply, LngEmail, 'ProgramEmail', 'Email' );
     386  Language.LL( Apply, LngNewsgroups, 'ProgramNewsgroups', 'Newsgroups' );
     387  Language.LL( Apply, LngFtp, 'ProgramFTP', 'FTP' );
     388  Language.LL( Apply, LngIrc, 'ProgramIRC', 'IRC' );
     389  Language.LL( Apply, LngDiscardChanges, 'DiscardChanges', 'Discard changes?' );
     390  Language.LL( Apply, LngExitAndDiscardChanges, 'ExitAndDiscardChanges', 'Exit and discard changes?' );
     391  Language.LL( Apply, LngFileDoesNotExist, 'FileDoesNotExist', 'File does not exist: ' );
     392  Language.LL( Apply, LngProgramNotFoundInPath, 'ProgramNotFoundInPath', 'Program not found in path: ' );
     393  Language.LL( Apply, LngDirectoryDoesNotExist, 'DirectoryDoesNotExist', 'Directory does not exist: ' );
     394  Language.LL( Apply, LngSaveAnyway, 'SaveAnyway', 'Save anyway?' );
     395
     396  ProgramNames[ idBrowser ] := LngWebBrowser;
     397  ProgramNames[ idMail ] := LngEmail;
     398  ProgramNames[ idNews ] := LngNewsgroups;
     399  ProgramNames[ idFTP ] := LngFtp;
     400  ProgramNames[ idIRC ] := LngIrc;
     401
     402End;
     403
    349404Initialization
    350405  RegisterClasses ([TMainForm, TEdit, TButton, TMultiColumnListBox, TLabel,
Note: See TracChangeset for help on using the changeset viewer.