Changeset 10


Ignore:
Timestamp:
Apr 22, 2016, 9:59:52 PM (8 years ago)
Author:
chronos
Message:
  • Added: Interface localization support.
Location:
trunk
Files:
32 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/AcronymDecoder.lpi

    r9 r10  
    1313    </General>
    1414    <i18n>
    15       <EnableI18N LFM="False"/>
     15      <EnableI18N Value="True"/>
     16      <OutDir Value="Languages"/>
    1617    </i18n>
    1718    <VersionInfo>
     
    6970      </local>
    7071    </RunParams>
    71     <RequiredPackages Count="4">
     72    <RequiredPackages Count="5">
    7273      <Item1>
     74        <PackageName Value="CoolTranslator"/>
     75        <DefaultFilename Value="Packages\CoolTranslator\CoolTranslator.lpk" Prefer="True"/>
     76      </Item1>
     77      <Item2>
    7378        <PackageName Value="TemplateGenerics"/>
    7479        <DefaultFilename Value="Packages\TemplateGenerics\TemplateGenerics.lpk" Prefer="True"/>
    75       </Item1>
    76       <Item2>
     80      </Item2>
     81      <Item3>
    7782        <PackageName Value="Common"/>
    7883        <DefaultFilename Value="Packages\Common\Common.lpk" Prefer="True"/>
    79       </Item2>
    80       <Item3>
     84      </Item3>
     85      <Item4>
    8186        <PackageName Value="synapse"/>
    8287        <DefaultFilename Value="Packages\synapse\synapse.lpk" Prefer="True"/>
    83       </Item3>
    84       <Item4>
     88      </Item4>
     89      <Item5>
    8590        <PackageName Value="LCL"/>
    86       </Item4>
     91      </Item5>
    8792    </RequiredPackages>
    88     <Units Count="5">
     93    <Units Count="6">
    8994      <Unit0>
    9095        <Filename Value="AcronymDecoder.lpr"/>
     
    116121        <ResourceBaseClass Value="Form"/>
    117122      </Unit4>
     123      <Unit5>
     124        <Filename Value="UFormSettings.pas"/>
     125        <IsPartOfProject Value="True"/>
     126        <ComponentName Value="FormSettings"/>
     127        <HasResources Value="True"/>
     128        <ResourceBaseClass Value="Form"/>
     129      </Unit5>
    118130    </Units>
    119131  </ProjectOptions>
     
    144156        <StackChecks Value="True"/>
    145157      </Checks>
    146       <VerifyObjMethodCallValidity Value="True"/>
    147158    </CodeGeneration>
    148159    <Linking>
  • trunk/AcronymDecoder.lpr

    r9 r10  
    99  Interfaces, // this includes the LCL widgetset
    1010  Forms, UFormMain, UAcronym, synapse, UFormImport, Common, SysUtils, TemplateGenerics,
    11   UFormAcronym
     11  UFormAcronym, CoolTranslator, UFormSettings
    1212  { you can add units after this };
    1313
     
    3333  Application.CreateForm(TFormImport, FormImport);
    3434  Application.CreateForm(TFormAcronym, FormAcronym);
     35  Application.CreateForm(TFormSettings, FormSettings);
    3536  Application.Run;
    3637end.
  • trunk/Packages/Common/Common.pas

    r9 r10  
    55unit Common;
    66
    7 {$warn 5023 off : no warning about unused units}
    87interface
    98
  • trunk/Packages/TemplateGenerics/TemplateGenerics.pas

    r9 r10  
    55unit TemplateGenerics;
    66
    7 {$warn 5023 off : no warning about unused units}
    87interface
    98
  • trunk/Packages/synapse/synapse.pas

    r9 r10  
    55unit synapse;
    66
    7 {$warn 5023 off : no warning about unused units}
    87interface
    98
  • trunk/UFormAcronym.lfm

    r8 r10  
    1313  object Label1: TLabel
    1414    Left = 8
    15     Height = 20
     15    Height = 24
    1616    Top = 16
    17     Width = 43
     17    Width = 60
    1818    Caption = 'Name:'
    1919    ParentColor = False
     
    2121  object EditAcronym: TEdit
    2222    Left = 136
    23     Height = 28
     23    Height = 34
    2424    Top = 15
    2525    Width = 272
     
    3030  object Label2: TLabel
    3131    Left = 8
    32     Height = 20
     32    Height = 24
    3333    Top = 49
    34     Width = 61
     34    Width = 83
    3535    Caption = 'Meaning:'
    3636    ParentColor = False
     
    3838  object EditMeaning: TEdit
    3939    Left = 136
    40     Height = 28
     40    Height = 34
    4141    Top = 49
    4242    Width = 272
     
    6969  object Label3: TLabel
    7070    Left = 8
    71     Height = 20
     71    Height = 24
    7272    Top = 88
    73     Width = 79
     73    Width = 109
    7474    Caption = 'Description:'
    7575    ParentColor = False
  • trunk/UFormImport.lfm

    r8 r10  
    2929  object ComboBoxDataFormat: TComboBox
    3030    Left = 256
    31     Height = 28
     31    Height = 34
    3232    Top = 5
    3333    Width = 140
    34     ItemHeight = 20
     34    ItemHeight = 0
    3535    ItemIndex = 0
    3636    Items.Strings = (
     
    4444  object Label1: TLabel
    4545    Left = 153
    46     Height = 20
     46    Height = 24
    4747    Top = 9
    48     Width = 84
     48    Width = 116
    4949    Caption = 'Data format:'
    5050    ParentColor = False
  • trunk/UFormImport.pas

    r8 r10  
    3838uses
    3939  UFormMain;
     40
     41resourcestring
     42  SImportedNewAcronyms = 'Imported %d new acronyms.';
    4043
    4144
     
    112115  end;
    113116  if AddedCount > 0 then FormMain.AcronymDb.Modified := True;
    114   ShowMessage(Format('Imported %d new acronyms.', [AddedCount]));
     117  ShowMessage(Format(SImportedNewAcronyms, [AddedCount]));
    115118end;
    116119
     
    159162  Columns.Free;
    160163  if AddedCount > 0 then FormMain.AcronymDb.Modified := True;
    161   ShowMessage(Format('Imported %d new acronyms.', [AddedCount]));
     164  ShowMessage(Format(SImportedNewAcronyms, [AddedCount]));
    162165end;
    163166
  • trunk/UFormMain.lfm

    r9 r10  
    11object FormMain: TFormMain
    2   Left = 534
     2  Left = 767
    33  Height = 446
    4   Top = 352
     4  Top = 445
    55  Width = 631
    66  Caption = 'Acronym Decoder'
     
    1313  OnDestroy = FormDestroy
    1414  OnShow = FormShow
    15   LCLVersion = '1.7'
     15  LCLVersion = '1.6.0.4'
    1616  object ListViewAcronyms: TListView
    1717    Left = 8
     
    43424342    Visible = True
    43434343    OnClick = TrayIcon1Click
    4344     left = 152
    4345     top = 256
     4344    left = 80
     4345    top = 272
    43464346  end
    43474347  object PopupMenuTryIcon: TPopupMenu
    4348     left = 144
    4349     top = 192
     4348    left = 80
     4349    top = 208
    43504350    object MenuItem2: TMenuItem
    43514351      Action = AShow
     
    43554355      Action = AImport
    43564356    end
     4357    object MenuItem19: TMenuItem
     4358      Action = ASettings
     4359    end
    43574360    object MenuItem1: TMenuItem
    43584361      Action = AExit
     
    43604363  end
    43614364  object ActionList1: TActionList
    4362     left = 465
    4363     top = 171
     4365    left = 464
     4366    top = 144
    43644367    object AExit: TAction
    43654368      Caption = 'Exit'
     
    44134416      OnExecute = AFileSaveAsExecute
    44144417    end
     4418    object ASettings: TAction
     4419      Caption = 'Settings'
     4420      OnExecute = ASettingsExecute
     4421    end
    44154422  end
    44164423  object PersistentForm1: TPersistentForm
    44174424    MinVisiblePart = 50
    44184425    EntireVisible = False
    4419     left = 304
    4420     top = 112
     4426    left = 264
     4427    top = 80
    44214428  end
    44224429  object PopupMenuAcronym: TPopupMenu
    4423     left = 359
    4424     top = 263
     4430    left = 264
     4431    top = 208
    44254432    object MenuItem4: TMenuItem
    44264433      Action = AAcronymAdd
     
    44374444  end
    44384445  object MainMenu1: TMainMenu
    4439     left = 465
    4440     top = 112
     4446    left = 464
     4447    top = 80
    44414448    object MenuItem8: TMenuItem
    44424449      Caption = 'File'
     
    44714478        Action = AImport
    44724479      end
     4480      object MenuItem18: TMenuItem
     4481        Action = ASettings
     4482      end
    44734483    end
    44744484  end
    44754485  object OpenDialog1: TOpenDialog
    4476     left = 151
    4477     top = 85
     4486    left = 80
     4487    top = 144
    44784488  end
    44794489  object SaveDialog1: TSaveDialog
    4480     left = 48
    4481     top = 85
     4490    left = 80
     4491    top = 88
    44824492  end
    44834493  object LastOpenedList1: TLastOpenedList
    44844494    MaxCount = 10
    44854495    OnChange = LastOpenedList1Change
    4486     left = 509
     4496    left = 264
    44874497    top = 267
    44884498  end
     4499  object CoolTranslator1: TCoolTranslator
     4500    POFilesFolder = 'Languages'
     4501    left = 264
     4502    top = 144
     4503  end
    44894504end
  • 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.