LCL, DefaultTranslator:

1) Fix translation of captions in different forms, but with the same values (don't take first found translation, check also message name) when using PO files.
  2) Create message name according to the rules used for creating it in LRT files after r25431 #99c23d89c7.
  3) Impove code readability.
  4) Cleanup.

git-svn-id: trunk@25440 -
This commit is contained in:
maxim 2010-05-15 18:16:07 +00:00
parent 9a50186700
commit 754af06409

View File

@ -1,6 +1,6 @@
unit DefaultTranslator; unit DefaultTranslator;
{ Copyright (C) 2004 V.I.Volchenko and Lazarus Developers Team { Copyright (C) 2004-2010 V.I.Volchenko and Lazarus Developers Team
This library is free software; you can redistribute it and/or modify it This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by under the terms of the GNU Library General Public License as published by
@ -214,7 +214,7 @@ begin
FMOFile.Free; FMOFile.Free;
//If someone will use this class incorrectly, it can be destroyed //If someone will use this class incorrectly, it can be destroyed
//before Reader destroying. It is a very bad thing, but in THIS situation //before Reader destroying. It is a very bad thing, but in THIS situation
//in this case is impossible. May be, in future we can overcome this difficulty //in this case is impossible. Maybe, in future we can overcome this difficulty
inherited Destroy; inherited Destroy;
end; end;
@ -243,26 +243,26 @@ begin
if (csDesigning in Component.ComponentState) then if (csDesigning in Component.ComponentState) then
exit; exit;
s := FMOFile.Translate(Content); if not (Sender is TReader) then
if s = '' then exit;
begin if Component = TReader(Sender).Root then
if not (Sender is TReader) then Section := Component.ClassName
Exit; else
if Component = TReader(Sender).Root then
Section := UpperCase(Component.ClassName)
else
if Component.Owner = TReader(Sender).Root then if Component.Owner = TReader(Sender).Root then
Section := UpperCase(Component.Owner.ClassName + '.' + Instance.GetNamePath) Section := Component.Owner.ClassName
else else
Exit; exit;
Section := Section + '.' + UpperCase(PropInfo^.Name); Section := UpperCase(Section + '.' + Instance.GetNamePath + '.' + PropInfo^.Name);
s := FMoFile.Translate(Section + #4 + Content); s := FMoFile.Translate(Section + #4 + Content);
end;
if s = '' then
s := FMOFile.Translate(Content);
if s <> '' then if s <> '' then
Content := s; Content := s;
end; end;
{ TDefaultTranslator } { TPOTranslator }
constructor TPOTranslator.Create(POFileName: string); constructor TPOTranslator.Create(POFileName: string);
begin begin
@ -304,21 +304,18 @@ begin
if (csDesigning in Component.ComponentState) then if (csDesigning in Component.ComponentState) then
exit; exit;
s := FPOFile.Translate(Content, Content); if not (Sender is TReader) then
if s = '' then exit;
begin if Component = TReader(Sender).Root then
if not (Sender is TReader) then Section := Component.ClassName
Exit;
if Component = TReader(Sender).Root then
Section := UpperCase(Component.ClassName)
else else
if Component.Owner = TReader(Sender).Root then if Component.Owner = TReader(Sender).Root then
Section := UpperCase(Component.Owner.ClassName + '.' + Instance.GetNamePath) Section := Component.Owner.ClassName
else else
Exit; exit;
Section := Section + '.' + UpperCase(PropInfo^.Name); Section := UpperCase(Section + '.' + Instance.GetNamePath + '.' + PropInfo^.Name);
s := FPOFile.Translate(Section + #4 + Content, Section + #4 + Content); s := FPOFile.Translate(Section, Content);
end;
if s <> '' then if s <> '' then
Content := s; Content := s;
end; end;
@ -382,7 +379,3 @@ finalization
LocalTranslator.Free; LocalTranslator.Free;
end. end.
{
No revision (not in LOG)
2004/10/09 Sent as is to Lazarus Team - VVI
}