Changeset 159 for trunk/Packages


Ignore:
Timestamp:
Jun 12, 2023, 11:46:36 PM (18 months ago)
Author:
chronos
Message:
  • Modified: Support multiple translator PO directories.
Location:
trunk/Packages
Files:
1 added
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Translator.pas

    r148 r159  
    4848    procedure TranslateProperty(Component: TPersistent; PropInfo: PPropInfo);
    4949    function IsExcluded(Component: TPersistent; PropertyName: string): Boolean;
    50     function GetLangFileDir: string;
     50    function GetLangFileDirs: TStrings;
    5151  public
    5252    ComponentExcludes: TComponentExcludesList;
     
    7171  end;
    7272
     73const
     74  PoExt = '.po';
     75
    7376procedure Register;
    7477
    7578
    7679implementation
     80
     81uses
     82  Common;
    7783
    7884procedure Register;
     
    161167  FileList: TStringList;
    162168  I: Integer;
     169  J: Integer;
    163170  LocaleShort: string;
    164171  SearchMask: string;
     172  LangDirs: TStrings;
    165173begin
    166174  FPoFiles.Clear;
     
    172180    SearchMask := '*';
    173181    if LocaleShort <> '' then SearchMask := SearchMask + '.' + LocaleShort;
    174     SearchMask := SearchMask + '.po';
    175     FileList := FindAllFiles(GetLangFileDir, SearchMask);
    176     for I := 0 to FileList.Count - 1 do begin
    177       FileName := FileList[I];
    178       //FileName := FindLocaleFileName('.po');
    179       if FileExists(FileName) and (
    180       ((LocaleShort = '') and (Pos('.', FileName) = Pos('.po', FileName))) or
    181       (LocaleShort <> '')) then FPoFiles.Add(TPOFile.Create(FileName));
    182     end;
     182    SearchMask := SearchMask + PoExt;
     183    LangDirs := GetLangFileDirs;
     184    for J := 0 to LangDirs.Count - 1 do begin
     185      FileList := FindAllFiles(LangDirs[J], SearchMask);
     186      for I := 0 to FileList.Count - 1 do begin
     187        FileName := FileList[I];
     188        //FileName := FindLocaleFileName('.po');
     189        if FileExists(FileName) and (
     190        ((LocaleShort = '') and (Pos('.', FileName) = Pos(PoExt, FileName))) or
     191        (LocaleShort <> '')) then FPoFiles.Add(TPOFile.Create(FileName));
     192      end;
     193    end;
     194    LangDirs.Free;
    183195  finally
    184196    FileList.Free;
     
    299311end;
    300312
    301 function TTranslator.GetLangFileDir: string;
    302 begin
    303   Result := FPoFilesFolder;
    304   if Copy(Result, 1, 1) <> DirectorySeparator then
    305     Result := ExtractFileDir(Application.ExeName) +
    306       DirectorySeparator + Result;
     313function TTranslator.GetLangFileDirs: TStrings;
     314var
     315  I: Integer;
     316begin
     317  Result := TStringList.Create;
     318  Result.Delimiter := ';';
     319  Result.StrictDelimiter := True;
     320  Result.DelimitedText := FPoFilesFolder;
     321
     322  for I := 0 to Result.Count - 1 do begin
     323    Result[I] := StringReplace(Result[I], '/', DirectorySeparator, [rfReplaceAll]);
     324    Result[I] := StringReplace(Result[I], '\', DirectorySeparator, [rfReplaceAll]);
     325    if Copy(Result[I], 1, 1) <> DirectorySeparator then
     326      Result[I] := ExtractFileDir(Application.ExeName) +
     327        DirectorySeparator + Result[I];
     328  end;
    307329end;
    308330
     
    371393var
    372394  I: Integer;
    373   LangDir: string;
    374 begin
    375   LangDir := GetLangFileDir;
     395  J: Integer;
     396  LangDirs: TStrings;
     397begin
     398  LangDirs := GetLangFileDirs;
    376399  Languages.SearchByCode('').Available := True; // Automatic
    377400
    378401  for I := 1 to Languages.Count - 1 do
    379402  with Languages[I] do begin
    380     Available := FileExists(LangDir + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) +
    381       '.' + Code + ExtensionSeparator + 'po') or (Code = 'en');
    382   end;
     403    for J := 0 to LangDirs.Count - 1 do begin
     404      if FileExists(LangDirs[J] + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) +
     405        '.' + Code + PoExt) or (Code = 'en') then begin
     406          Available := True;
     407          Continue;
     408        end;
     409    end;
     410  end;
     411  LangDirs.Free;
    383412end;
    384413
  • trunk/Packages/SynEditEx/SynEditEx.lpk

    r128 r159  
    3030    <Files>
    3131      <Item>
    32         <Filename Value="USynEditEx.pas"/>
     32        <Filename Value="SynEditEx.pas"/>
    3333        <HasRegisterProc Value="True"/>
    34         <UnitName Value="USynEditEx"/>
     34        <UnitName Value="SynEditEx"/>
     35      </Item>
     36      <Item>
     37        <Filename Value="SynEditExPackage.pas"/>
     38        <Type Value="Main Unit"/>
     39        <UnitName Value="SynEditExPackage"/>
    3540      </Item>
    3641    </Files>
  • trunk/Packages/SynEditEx/SynEditEx.pas

    r158 r159  
    1 unit USynEditEx;
     1unit SynEditEx;
    22
    33interface
     
    2828end;
    2929
    30 
    3130{ TSynEditEx }
    3231
     
    3837end;
    3938
    40 
    4139end.
    4240
Note: See TracChangeset for help on using the changeset viewer.