Changeset 10 for trunk/UFormMain.pas


Ignore:
Timestamp:
Apr 22, 2016, 9:59:52 PM (9 years ago)
Author:
chronos
Message:
  • Added: Interface localization support.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UFormMain.pas

    r9 r10  
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
    99  ComCtrls, StdCtrls, ExtCtrls, ActnList, UAcronym, UPersistentForm, Contnrs,
    10   URegistry, ULastOpenedList, Registry;
     10  URegistry, ULastOpenedList, UCoolTranslator, Registry;
    1111
    1212type
     
    1919    AAcronymRemove: TAction;
    2020    AAcronymRemoveAll: TAction;
     21    ASettings: TAction;
    2122    AFileSaveAs: TAction;
    2223    AFileClose: TAction;
     
    2829    AExit: TAction;
    2930    ActionList1: TActionList;
     31    CoolTranslator1: TCoolTranslator;
    3032    EditSearch: TEdit;
    3133    LastOpenedList1: TLastOpenedList;
     
    4143    MenuItem16: TMenuItem;
    4244    MenuItem17: TMenuItem;
     45    MenuItem18: TMenuItem;
     46    MenuItem19: TMenuItem;
    4347    MenuItemOpenRecent: TMenuItem;
    4448    MenuItem2: TMenuItem;
     
    6771    procedure AFileSaveExecute(Sender: TObject);
    6872    procedure AImportExecute(Sender: TObject);
     73    procedure ASettingsExecute(Sender: TObject);
    6974    procedure AShowExecute(Sender: TObject);
    7075    procedure EditSearchChange(Sender: TObject);
     
    101106
    102107uses
    103   UFormImport, UFormAcronym;
     108  UFormImport, UFormAcronym, UFormSettings;
     109
     110resourcestring
     111  SModified = 'modified';
     112  SAppExit = 'Application exit';
     113  SAppExitQuery = 'Acronyms were modified. Do you want to save them to file before exit?';
     114  SRemoveAllAcronyms = 'Remove all acronyms';
     115  SRemoveAllAcronymsQuery = 'Do you want to remove all acronyms?';
     116  SRemoveAcronym = 'Remove acronym';
     117  SRemoveAcronymQuery = 'Do you want to remove selected acronym?';
    104118
    105119const
     
    133147begin
    134148  if Assigned(AcronymDb) and AcronymDb.Modified then begin
    135     ModalResult := MessageDlg('Application exit',
    136     'Acronyms were modified. Do you want to save them to file before exit?',
     149    ModalResult := MessageDlg(SAppExit, SAppExitQuery,
    137150      mtConfirmation, [mbYes, mbNo, mbCancel], 0);
    138151    if ModalResult = mrYes then begin
     
    237250procedure TFormMain.AAcronymRemoveAllExecute(Sender: TObject);
    238251begin
    239   if MessageDlg('Remove all acronyms', 'Do you want to remove all acronyms?',
     252  if MessageDlg(SRemoveAllAcronyms, SRemoveAllAcronymsQuery,
    240253  TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
    241254    AcronymDb.Acronyms.Clear;
     
    249262begin
    250263  if Assigned(ListViewAcronyms.Selected) then begin
    251     if MessageDlg('Remove acronym', 'Do you want to remove selected acronym?',
     264    if MessageDlg(SRemoveAcronym, SRemoveAcronymQuery,
    252265    TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
    253266      AcronymDb.RemoveAcronym(TAcronymMeaning(ListViewAcronyms.Selected.Data).Acronym.Name,
     
    285298end;
    286299
     300procedure TFormMain.ASettingsExecute(Sender: TObject);
     301begin
     302  FormSettings.ShowModal;
     303end;
     304
    287305procedure TFormMain.AShowExecute(Sender: TObject);
    288306begin
     
    387405  Title := Application.Title;
    388406  if Assigned(AcronymDb) then Title := Title + ' - ' + ExtractFileName(AcronymDb.FileName);
    389   if Assigned(AcronymDb) and AcronymDb.Modified then Title := Title + ' (modified)';
     407  if Assigned(AcronymDb) and AcronymDb.Modified then Title := Title + ' (' + SModified + ')';
    390408  Caption := Title;
    391409end;
     
    396414  PersistentForm1.RegistryContext := RegistryContext;
    397415  LastOpenedList1.LoadFromRegistry(RegistryContext);
     416
     417  with TRegistryEx.Create do
     418  try
     419    RootKey := HKEY_CURRENT_USER;
     420    OpenKey(DefaultRegKey, True);
     421    if ValueExists('LanguageCode') then
     422      CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', ''))
     423      else CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode('');
     424  finally
     425    Free;
     426  end;
    398427end;
    399428
     
    401430begin
    402431  LastOpenedList1.SaveToRegistry(RegistryContext);
     432
     433  with TRegistryEx.Create do
     434  try
     435    RootKey := HKEY_CURRENT_USER;
     436    OpenKey(DefaultRegKey, True);
     437    if Assigned(CoolTranslator1.Language) and (CoolTranslator1.Language.Code <> '') then
     438      WriteString('LanguageCode', CoolTranslator1.Language.Code)
     439      else DeleteValue('LanguageCode');
     440  finally
     441    Free;
     442  end;
    403443end;
    404444
Note: See TracChangeset for help on using the changeset viewer.