Changeset 159 for trunk/Packages/Common/Translator.pas
- Timestamp:
- Jun 12, 2023, 11:46:36 PM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Translator.pas
r148 r159 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; … … 172 180 SearchMask := '*'; 173 181 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; 183 195 finally 184 196 FileList.Free; … … 299 311 end; 300 312 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; 313 function TTranslator.GetLangFileDirs: TStrings; 314 var 315 I: Integer; 316 begin 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; 307 329 end; 308 330 … … 371 393 var 372 394 I: Integer; 373 LangDir: string; 374 begin 375 LangDir := GetLangFileDir; 395 J: Integer; 396 LangDirs: TStrings; 397 begin 398 LangDirs := GetLangFileDirs; 376 399 Languages.SearchByCode('').Available := True; // Automatic 377 400 378 401 for I := 1 to Languages.Count - 1 do 379 402 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; 383 412 end; 384 413
Note:
See TracChangeset
for help on using the changeset viewer.