Changeset 123 for tags


Ignore:
Timestamp:
Dec 10, 2016, 7:19:34 PM (8 years ago)
Author:
chronos
Message:

Merged revision(s) 121-122 from trunk:

  • Modified: Updated CoolTranslator package.
  • Fixed: Set correct Windows registry path for storing form size.
  • Fixed: Set correct path for Config.xml file.
Location:
tags/1.0.0
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tags/1.0.0

  • tags/1.0.0/Packages/CoolTranslator/UCoolTranslator.pas

    r95 r123  
    66
    77uses
    8   Classes, SysUtils, Forms, ExtCtrls, Controls, Contnrs,
     8  Classes, SysUtils, Forms, ExtCtrls, Controls, Contnrs, LazFileUtils, LazUTF8,
    99  Translations, TypInfo, Dialogs, FileUtil, LCLProc, ULanguages, LCLType;
    1010
     
    4646    procedure TranslateProperty(Component: TPersistent; PropInfo: PPropInfo);
    4747    function IsExcluded(Component: TPersistent; PropertyName: string): Boolean;
     48    function GetLangFileDir: string;
    4849  public
    4950    ComponentExcludes: TComponentExcludesList;
     
    150151  I: Integer;
    151152  LocaleShort: string;
    152   Dir: string;
     153  SearchMask: string;
    153154begin
    154155  FPOFiles.Clear;
     
    158159    //ShowMessage(ExtractFileDir(Application.ExeName) +
    159160    //  DirectorySeparator + 'Languages' + ' ' + '*.' + LocaleShort + '.po');
    160     Dir := FPOFilesFolder;
    161     if Copy(Dir, 1, 1) <> DirectorySeparator then
    162       Dir := ExtractFileDir(UTF8Encode(Application.ExeName)) +
    163       DirectorySeparator + Dir;
    164     FileList := FindAllFiles(Dir, '*.' + LocaleShort + '.po');
     161    SearchMask := '*';
     162    if LocaleShort <> '' then SearchMask := SearchMask + '.' + LocaleShort;
     163    SearchMask := SearchMask + '.po';
     164    FileList := FindAllFiles(GetLangFileDir, SearchMask);
    165165    for I := 0 to FileList.Count - 1 do begin
    166166      FileName := FileList[I];
    167167      //FileName := FindLocaleFileName('.po');
    168       if FileExistsUTF8(FileName) then FPOFiles.Add(TPOFile.Create(FileName));
     168      if FileExists(FileName) and (
     169      ((LocaleShort = '') and (Pos('.', FileName) = Pos('.po', FileName))) or
     170      (LocaleShort <> '')) then FPOFiles.Add(TPOFile.Create(FileName));
    169171    end;
    170172  finally
     
    289291end;
    290292
     293function TCoolTranslator.GetLangFileDir: string;
     294begin
     295  Result := FPOFilesFolder;
     296  if Copy(Result, 1, 1) <> DirectorySeparator then
     297    Result := ExtractFileDir(UTF8Encode(Application.ExeName)) +
     298      DirectorySeparator + Result;
     299end;
     300
    291301procedure TCoolTranslator.LanguageListToStrings(Strings: TStrings);
    292302var
     
    321331  I: Integer;
    322332begin
     333  Result := '';
    323334  if Text <> '' then begin
    324335    for I := 0 to FPoFiles.Count - 1 do begin
     
    347358var
    348359  I: Integer;
    349 begin
     360  LangDir: string;
     361begin
     362  LangDir := GetLangFileDir;
    350363  TLanguage(Languages[0]).Available := True; // Automatic
    351364
    352365  for I := 1 to Languages.Count - 1 do
    353366  with TLanguage(Languages[I]) do begin
    354     Available := FileExistsUTF8(POFilesFolder + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) +
     367    Available := FileExists(LangDir + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) +
    355368      '.' + Code + ExtensionSeparator + 'po') or (Code = 'en');
    356369  end;
     
    364377  Languages := TLanguageList.Create;
    365378  POFilesFolder := 'Languages';
     379  CheckLanguageFiles;
    366380
    367381  // LCL
     
    386400begin
    387401  // Win32 user may decide to override locale with LANG variable.
    388   Lang := GetEnvironmentVariableUTF8('LANG');
     402  Lang := GetEnvironmentVariable('LANG');
    389403
    390404  // Use user selected language
     
    394408  if Lang = '' then begin
    395409    for i := 1 to Paramcount - 1 do
    396       if (ParamStrUTF8(i) = '--LANG') or (ParamStrUTF8(i) = '-l') or
    397         (ParamStrUTF8(i) = '--lang') then
    398         Lang := ParamStrUTF8(i + 1);
     410      if (ParamStr(i) = '--LANG') or (ParamStr(i) = '-l') or
     411        (ParamStr(i) = '--lang') then
     412        Lang := ParamStr(i + 1);
    399413  end;
    400414  if Lang = '' then
     
    404418    Lang := FOnAutomaticLanguage(Lang);
    405419  end;
    406 
    407   if Lang = 'en' then Lang := ''; // English files are without en code
    408420
    409421  Result := Lang;
     
    427439    Exit;
    428440
    429   Result := ChangeFileExt(ParamStrUTF8(0), LCExt);
     441  Result := ChangeFileExt(ParamStr(0), LCExt);
    430442  if FileExistsUTF8(Result) then
    431443    Exit;
  • tags/1.0.0/UCore.pas

    r117 r123  
    77uses
    88  Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, Dialogs, Forms,
    9   UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator;
     9  UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator, URegistry,
     10  Registry;
    1011
    1112type
     
    5051    FInitialized: Boolean;
    5152    StoredDimension: TControlDimension;
     53    RegistryContext: TRegistryContext;
    5254    procedure DoOnMove(CellFrom, CellTo: TCell; var CountOnce,
    5355      CountRepeat: Integer; Update: Boolean; var Confirm: Boolean);
     
    8587  UFormHelp;
    8688
     89const
     90  DefaultRegKey = '\Software\Chronosoft\xTactics';
     91
    8792resourcestring
    8893  SPlayerWins = 'Player %s wins';
     
    157162procedure TCore.LoadConfig;
    158163begin
     164  RegistryContext := RegContext(HKEY_CURRENT_USER, DefaultRegKey);
     165  PersistentForm.RegistryContext := RegistryContext;
     166  XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml';
     167
    159168  LastMapFileName := XMLConfig1.GetValue('LastMapFileName', '');
    160169  DevelMode := XMLConfig1.GetValue('DevelMode', false);
Note: See TracChangeset for help on using the changeset viewer.