Changeset 416 for trunk/Start.pas


Ignore:
Timestamp:
Nov 17, 2021, 10:47:48 AM (3 years ago)
Author:
chronos
Message:
  • Fixed: Use Common package translator to solve duplicate ULanguages unit name.
  • Modified: Also automatically detect new localizations in Localization directory.
  • Fixed: Use localization files with first capital letter to work correctly on Linux.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Start.pas

    r385 r416  
    77  GameServer, Messg, ButtonBase, ButtonA, ButtonC, ButtonB, Area, Types,
    88  LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls,
    9   Menus, Registry,  DrawDlg, fgl, Protocol, UMiniMap, UBrain;
     9  Menus, Registry,  DrawDlg, fgl, Protocol, UMiniMap, UBrain, UTranslator;
    1010
    1111type
     
    133133    procedure LoadConfig;
    134134    procedure SaveConfig;
     135    procedure LoadLanguages;
    135136    procedure LoadAiBrainsPictures;
    136137    procedure UpdateInterface;
     
    138139  public
    139140    EmptyPicture: TBitmap;
     141    Translator: TTranslator;
    140142    procedure UpdateFormerGames;
    141143    procedure UpdateMaps;
     
    149151
    150152uses
    151   Global, Directories, Direct, ScreenTools, Inp, Back, Settings, UKeyBindings;
     153  Global, Directories, Direct, ScreenTools, Inp, Back, Settings, UKeyBindings,
     154  ULanguages;
    152155
    153156{$R *.lfm}
     
    226229  LoadConfig;
    227230  LoadAssets;
     231  LoadLanguages;
    228232
    229233  ActionsOffered := [maConfig, maManual, maCredits, maWeb];
     
    325329begin
    326330  SaveConfig;
     331  FreeAndNil(Translator);
    327332  FreeAndNil(FormerGames);
    328333  FreeAndNil(Maps);
     
    454459
    455460  KeyBindings.SaveToRegistry(HKEY_CURRENT_USER, AppRegistryKey + '\KeyBindings');
     461end;
     462
     463procedure TStartDlg.LoadLanguages;
     464var
     465  I: Integer;
     466begin
     467  Translator := TTranslator.Create(nil);
     468  with Translator, Languages do begin
     469    AddNew('zh-Hant', 'Traditional Chinese');
     470    AddNew('zh-Hans', 'Simplified Chinese');
     471    SearchByCode('').Available := True;
     472
     473    for I := 1 to Languages.Count - 1 do
     474    with Languages[I] do begin
     475      Available := DirectoryExists(HomeDir + 'Localization' + DirectorySeparator + Code) or (Code = 'en');
     476    end;
     477  end;
    456478end;
    457479
Note: See TracChangeset for help on using the changeset viewer.