- Timestamp:
- Dec 10, 2016, 7:19:34 PM (8 years ago)
- 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 6 6 7 7 uses 8 Classes, SysUtils, Forms, ExtCtrls, Controls, Contnrs, 8 Classes, SysUtils, Forms, ExtCtrls, Controls, Contnrs, LazFileUtils, LazUTF8, 9 9 Translations, TypInfo, Dialogs, FileUtil, LCLProc, ULanguages, LCLType; 10 10 … … 46 46 procedure TranslateProperty(Component: TPersistent; PropInfo: PPropInfo); 47 47 function IsExcluded(Component: TPersistent; PropertyName: string): Boolean; 48 function GetLangFileDir: string; 48 49 public 49 50 ComponentExcludes: TComponentExcludesList; … … 150 151 I: Integer; 151 152 LocaleShort: string; 152 Dir: string;153 SearchMask: string; 153 154 begin 154 155 FPOFiles.Clear; … … 158 159 //ShowMessage(ExtractFileDir(Application.ExeName) + 159 160 // 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); 165 165 for I := 0 to FileList.Count - 1 do begin 166 166 FileName := FileList[I]; 167 167 //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)); 169 171 end; 170 172 finally … … 289 291 end; 290 292 293 function TCoolTranslator.GetLangFileDir: string; 294 begin 295 Result := FPOFilesFolder; 296 if Copy(Result, 1, 1) <> DirectorySeparator then 297 Result := ExtractFileDir(UTF8Encode(Application.ExeName)) + 298 DirectorySeparator + Result; 299 end; 300 291 301 procedure TCoolTranslator.LanguageListToStrings(Strings: TStrings); 292 302 var … … 321 331 I: Integer; 322 332 begin 333 Result := ''; 323 334 if Text <> '' then begin 324 335 for I := 0 to FPoFiles.Count - 1 do begin … … 347 358 var 348 359 I: Integer; 349 begin 360 LangDir: string; 361 begin 362 LangDir := GetLangFileDir; 350 363 TLanguage(Languages[0]).Available := True; // Automatic 351 364 352 365 for I := 1 to Languages.Count - 1 do 353 366 with TLanguage(Languages[I]) do begin 354 Available := FileExists UTF8(POFilesFolder + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) +367 Available := FileExists(LangDir + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) + 355 368 '.' + Code + ExtensionSeparator + 'po') or (Code = 'en'); 356 369 end; … … 364 377 Languages := TLanguageList.Create; 365 378 POFilesFolder := 'Languages'; 379 CheckLanguageFiles; 366 380 367 381 // LCL … … 386 400 begin 387 401 // Win32 user may decide to override locale with LANG variable. 388 Lang := GetEnvironmentVariable UTF8('LANG');402 Lang := GetEnvironmentVariable('LANG'); 389 403 390 404 // Use user selected language … … 394 408 if Lang = '' then begin 395 409 for i := 1 to Paramcount - 1 do 396 if (ParamStr UTF8(i) = '--LANG') or (ParamStrUTF8(i) = '-l') or397 (ParamStr UTF8(i) = '--lang') then398 Lang := ParamStr UTF8(i + 1);410 if (ParamStr(i) = '--LANG') or (ParamStr(i) = '-l') or 411 (ParamStr(i) = '--lang') then 412 Lang := ParamStr(i + 1); 399 413 end; 400 414 if Lang = '' then … … 404 418 Lang := FOnAutomaticLanguage(Lang); 405 419 end; 406 407 if Lang = 'en' then Lang := ''; // English files are without en code408 420 409 421 Result := Lang; … … 427 439 Exit; 428 440 429 Result := ChangeFileExt(ParamStr UTF8(0), LCExt);441 Result := ChangeFileExt(ParamStr(0), LCExt); 430 442 if FileExistsUTF8(Result) then 431 443 Exit; -
tags/1.0.0/UCore.pas
r117 r123 7 7 uses 8 8 Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, Dialogs, Forms, 9 UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator; 9 UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator, URegistry, 10 Registry; 10 11 11 12 type … … 50 51 FInitialized: Boolean; 51 52 StoredDimension: TControlDimension; 53 RegistryContext: TRegistryContext; 52 54 procedure DoOnMove(CellFrom, CellTo: TCell; var CountOnce, 53 55 CountRepeat: Integer; Update: Boolean; var Confirm: Boolean); … … 85 87 UFormHelp; 86 88 89 const 90 DefaultRegKey = '\Software\Chronosoft\xTactics'; 91 87 92 resourcestring 88 93 SPlayerWins = 'Player %s wins'; … … 157 162 procedure TCore.LoadConfig; 158 163 begin 164 RegistryContext := RegContext(HKEY_CURRENT_USER, DefaultRegKey); 165 PersistentForm.RegistryContext := RegistryContext; 166 XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml'; 167 159 168 LastMapFileName := XMLConfig1.GetValue('LastMapFileName', ''); 160 169 DevelMode := XMLConfig1.GetValue('DevelMode', false);
Note:
See TracChangeset
for help on using the changeset viewer.