~chronoscz/acronymdecoder/trunk

« back to all changes in this revision

Viewing changes to Packages/Common/UTranslator.pas

  • Committer: chronos
  • Date: 2022-01-22 15:21:47 UTC
  • Revision ID: svn-v4:555d2374-d668-43ce-8d1e-0714718c3872:trunk:218
* Fixed: Relative path detection for language files directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
 
75
75
procedure Register;
76
76
 
 
77
const
 
78
  PoFileExt = '.po';
 
79
 
77
80
 
78
81
implementation
79
82
 
169
172
  if Assigned(FLanguage) then
170
173
  try
171
174
    LocaleShort := GetLocaleShort;
172
 
    //ShowMessage(ExtractFileDir(Application.ExeName) +
173
 
    //  DirectorySeparator + 'Languages' + ' ' + '*.' + LocaleShort + '.po');
174
175
    SearchMask := '*';
175
176
    if LocaleShort <> '' then SearchMask := SearchMask + '.' + LocaleShort;
176
 
    SearchMask := SearchMask + '.po';
 
177
    SearchMask := SearchMask + PoFileExt;
177
178
    FileList := FindAllFiles(GetLangFileDir, SearchMask);
178
179
    for I := 0 to FileList.Count - 1 do begin
179
180
      FileName := FileList[I];
180
 
      //FileName := FindLocaleFileName('.po');
181
181
      if FileExists(FileName) and (
182
 
      ((LocaleShort = '') and (Pos('.', FileName) = Pos('.po', FileName))) or
 
182
      ((LocaleShort = '') and (Pos('.', FileName) = Pos(PoFileExt, FileName))) or
183
183
      (LocaleShort <> '')) then FPoFiles.Add(TPOFile.Create(FileName));
184
184
    end;
185
185
  finally
244
244
  Obj: TObject;
245
245
  I: Integer;
246
246
begin
247
 
 
248
247
//  PropInfo^.Name;
249
248
  // Using IsDefaultPropertyValue will tell us if we should write out
250
249
  // a given property because it was different from the default or
289
288
  Result := False;
290
289
  Item := Component.ClassType;
291
290
  while Assigned(Item) do begin
292
 
    //ShowMessage(Component.Name + ', ' + Component.ClassName + ', ' + Item.ClassName + ', ' + PropertyName);
293
291
    Excludes := ComponentExcludes.FindByClassType(Item.ClassType);
294
292
    if Assigned(Excludes) then begin
295
293
      if Excludes.PropertyExcludes.IndexOf(PropertyName) <> -1 then begin
304
302
function TTranslator.GetLangFileDir: string;
305
303
begin
306
304
  Result := FPoFilesFolder;
307
 
  if Copy(Result, 1, 1) <> DirectorySeparator then
308
 
    Result := ExtractFileDir(Application.ExeName) +
309
 
      DirectorySeparator + Result;
 
305
  if not FilenameIsAbsolute(Result) then
 
306
    Result := ExtractFileDir(Application.ExeName) + DirectorySeparator + Result;
310
307
end;
311
308
 
312
309
procedure TTranslator.LanguageListToStrings(Strings: TStrings; WithCode: Boolean = True);
381
378
  for I := 1 to Languages.Count - 1 do
382
379
  with Languages[I] do begin
383
380
    Available := FileExists(LangDir + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) +
384
 
      '.' + Code + ExtensionSeparator + 'po') or (Code = 'en');
 
381
      '.' + Code + PoFileExt) or (Code = 'en');
385
382
  end;
386
383
end;
387
384
 
470
467
  if LangID <> '' then FormatLang := '.%s' else FormatLang := '';
471
468
 
472
469
  begin
473
 
 
474
470
    // ParamStrUTF8(0) is said not to work properly in linux, but I've tested it
475
471
    Result := ExtractFilePath(ParamStrUTF8(0)) + LangID +
476
472
      DirectorySeparator + ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), LCExt);