Changeset 566 for Common/Translator.pas
- Timestamp:
- Jun 29, 2023, 11:23:03 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/Translator.pas
r563 r566 48 48 procedure TranslateProperty(Component: TPersistent; PropInfo: PPropInfo); 49 49 function IsExcluded(Component: TPersistent; PropertyName: string): Boolean; 50 function GetLangFileDir : string;50 function GetLangFileDirs: TStrings; 51 51 public 52 52 ComponentExcludes: TComponentExcludesList; … … 71 71 end; 72 72 73 const 74 PoExt = '.po'; 75 73 76 procedure Register; 74 77 75 78 76 79 implementation 80 81 uses 82 Common; 77 83 78 84 procedure Register; … … 161 167 FileList: TStringList; 162 168 I: Integer; 169 J: Integer; 163 170 LocaleShort: string; 164 171 SearchMask: string; 172 LangDirs: TStrings; 165 173 begin 166 174 FPoFiles.Clear; 167 if Assigned(FLanguage) then 168 try 175 if Assigned(FLanguage) then begin 169 176 LocaleShort := GetLocaleShort; 170 //ShowMessage(ExtractFileDir(Application.ExeName) +171 // DirectorySeparator + 'Languages' + ' ' + '*.' + LocaleShort + '.po');172 177 SearchMask := '*'; 173 178 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; 183 finally 184 FileList.Free; 179 SearchMask := SearchMask + PoExt; 180 LangDirs := GetLangFileDirs; 181 for J := 0 to LangDirs.Count - 1 do begin 182 FileList := FindAllFiles(LangDirs[J], SearchMask); 183 try 184 for I := 0 to FileList.Count - 1 do begin 185 FileName := FileList[I]; 186 //FileName := FindLocaleFileName('.po'); 187 if FileExists(FileName) and ( 188 ((LocaleShort = '') and (Pos('.', FileName) = Pos(PoExt, FileName))) or 189 (LocaleShort <> '')) then FPoFiles.Add(TPOFile.Create(FileName)); 190 end; 191 finally 192 FileList.Free; 193 end; 194 end; 195 LangDirs.Free; 185 196 end; 186 197 end; … … 299 310 end; 300 311 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; 312 function TTranslator.GetLangFileDirs: TStrings; 313 var 314 I: Integer; 315 begin 316 Result := TStringList.Create; 317 Result.Delimiter := ';'; 318 Result.StrictDelimiter := True; 319 Result.DelimitedText := FPoFilesFolder; 320 321 for I := 0 to Result.Count - 1 do begin 322 Result[I] := StringReplace(Result[I], '/', DirectorySeparator, [rfReplaceAll]); 323 Result[I] := StringReplace(Result[I], '\', DirectorySeparator, [rfReplaceAll]); 324 if Copy(Result[I], 1, 1) <> DirectorySeparator then 325 Result[I] := ExtractFileDir(Application.ExeName) + 326 DirectorySeparator + Result[I]; 327 end; 307 328 end; 308 329 … … 371 392 var 372 393 I: Integer; 373 LangDir: string; 374 begin 375 LangDir := GetLangFileDir; 394 J: Integer; 395 LangDirs: TStrings; 396 begin 397 LangDirs := GetLangFileDirs; 376 398 Languages.SearchByCode('').Available := True; // Automatic 377 399 378 400 for I := 1 to Languages.Count - 1 do 379 401 with Languages[I] do begin 380 Available := FileExists(LangDir + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) + 381 '.' + Code + ExtensionSeparator + 'po') or (Code = 'en'); 382 end; 402 for J := 0 to LangDirs.Count - 1 do begin 403 if FileExists(LangDirs[J] + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) + 404 '.' + Code + PoExt) or (Code = 'en') then begin 405 Available := True; 406 Continue; 407 end; 408 end; 409 end; 410 LangDirs.Free; 383 411 end; 384 412
Note:
See TracChangeset
for help on using the changeset viewer.