From 754af0640979275a29b952541b2874e9114a7fe2 Mon Sep 17 00:00:00 2001 From: maxim Date: Sat, 15 May 2010 18:16:07 +0000 Subject: [PATCH] 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 - --- lcl/defaulttranslator.pas | 61 +++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/lcl/defaulttranslator.pas b/lcl/defaulttranslator.pas index f572b4a02d..fde9ff17f0 100644 --- a/lcl/defaulttranslator.pas +++ b/lcl/defaulttranslator.pas @@ -1,6 +1,6 @@ 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 under the terms of the GNU Library General Public License as published by @@ -214,7 +214,7 @@ begin FMOFile.Free; //If someone will use this class incorrectly, it can be destroyed //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; end; @@ -243,26 +243,26 @@ begin if (csDesigning in Component.ComponentState) then exit; - s := FMOFile.Translate(Content); - if s = '' then - begin - if not (Sender is TReader) then - Exit; - if Component = TReader(Sender).Root then - Section := UpperCase(Component.ClassName) - else + if not (Sender is TReader) then + exit; + if Component = TReader(Sender).Root then + Section := Component.ClassName + else if Component.Owner = TReader(Sender).Root then - Section := UpperCase(Component.Owner.ClassName + '.' + Instance.GetNamePath) + Section := Component.Owner.ClassName else - Exit; - Section := Section + '.' + UpperCase(PropInfo^.Name); - s := FMoFile.Translate(Section + #4 + Content); - end; + exit; + Section := UpperCase(Section + '.' + Instance.GetNamePath + '.' + PropInfo^.Name); + s := FMoFile.Translate(Section + #4 + Content); + + if s = '' then + s := FMOFile.Translate(Content); + if s <> '' then Content := s; end; -{ TDefaultTranslator } +{ TPOTranslator } constructor TPOTranslator.Create(POFileName: string); begin @@ -304,21 +304,18 @@ begin if (csDesigning in Component.ComponentState) then exit; - s := FPOFile.Translate(Content, Content); - if s = '' then - begin - if not (Sender is TReader) then - Exit; - if Component = TReader(Sender).Root then - Section := UpperCase(Component.ClassName) + if not (Sender is TReader) then + exit; + if Component = TReader(Sender).Root then + Section := Component.ClassName else - if Component.Owner = TReader(Sender).Root then - Section := UpperCase(Component.Owner.ClassName + '.' + Instance.GetNamePath) - else - Exit; - Section := Section + '.' + UpperCase(PropInfo^.Name); - s := FPOFile.Translate(Section + #4 + Content, Section + #4 + Content); - end; + if Component.Owner = TReader(Sender).Root then + Section := Component.Owner.ClassName + else + exit; + Section := UpperCase(Section + '.' + Instance.GetNamePath + '.' + PropInfo^.Name); + s := FPOFile.Translate(Section, Content); + if s <> '' then Content := s; end; @@ -382,7 +379,3 @@ finalization LocalTranslator.Free; end. -{ -No revision (not in LOG) - 2004/10/09 Sent as is to Lazarus Team - VVI -}