Ignore:
Timestamp:
Nov 29, 2023, 2:35:44 PM (12 months ago)
Author:
chronos
Message:
  • Modified: HighDpi branch updated to trunk version.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Packages/Common/Languages.pas

    r462 r463  
    1 unit ULanguages;
    2 
    3 {$mode objfpc}{$H+}
     1unit Languages;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, Contnrs;
     6  Classes, SysUtils, Generics.Collections;
    97
    108type
     
    1513  end;
    1614
    17   { TLanguageList }
    18 
    19   TLanguageList = class(TObjectList)
     15  { TLanguages }
     16
     17  TLanguages = class(TObjectList<TLanguage>)
    2018    function SearchByCode(ACode: string): TLanguage;
    2119    procedure AddNew(Code: string; Name: string);
    22     constructor Create;
     20    constructor Create(FreeObjects: Boolean = True);
    2321  end;
    2422
     
    218216  SLang_za = 'Zhuang';
    219217  SLang_zh = 'Chinese';
     218  SLang_zh_Hans = 'Simplified Chinese';
     219  SLang_zh_Hant = 'Traditional Chinese';
    220220  SLang_zu = 'Zulu';
    221221
     222
    222223implementation
    223224
    224225
    225 { TLanguageList }
    226 
    227 function TLanguageList.SearchByCode(ACode: string): TLanguage;
     226{ TLanguages }
     227
     228function TLanguages.SearchByCode(ACode: string): TLanguage;
    228229var
    229230  I: Integer;
    230231begin
    231232  I := 0;
    232   while (I < Count) and (TLanguage(Items[I]).Code < ACode) do Inc(I);
    233   if I < Count then Result := TLanguage(Items[I])
     233  while (I < Count) and (Items[I].Code <> ACode) do Inc(I);
     234  if I < Count then Result := Items[I]
    234235    else Result := nil;
    235236end;
    236237
    237 procedure TLanguageList.AddNew(Code: string; Name: string);
     238procedure TLanguages.AddNew(Code: string; Name: string);
    238239var
    239240  NewItem: TLanguage;
     
    245246end;
    246247
    247 constructor TLanguageList.Create;
     248constructor TLanguages.Create(FreeObjects: Boolean);
    248249begin
    249   inherited Create;
     250  inherited;
    250251  AddNew('', SLangAuto);
    251252  AddNew('aa', SLang_aa);
     
    441442  AddNew('za', SLang_za);
    442443  AddNew('zh', SLang_zh);
     444  AddNew('zh-Hant', SLang_zh_Hant);
     445  AddNew('zh-Hans', SLang_zh_Hans);
    443446  AddNew('zu', SLang_zu);
    444447end;
    445448
    446449end.
    447 
Note: See TracChangeset for help on using the changeset viewer.