On 01/03/2008, Graeme Geldenhuys <[EMAIL PROTECTED]> wrote:
>
> 2) In the code below (TPOFile.Translate), the first lookup using
> FIdentifierToItem.Data[] always returns nil. It seems that the lookup
> via the Identifier (eg: gfx_constants.rsLanguage) always fails. Has
> anybody else noticed this in the LCL as well?
OK, I found the bug..... The character between the unitname and the
resourcestring identifier is different. Here is some debug output
showing the issue...
In TPOFile.Add() the Identifier has a ':' delimiter....
TPOFile.Add: gfx_constants:rslanguage | English | Afrikaans
TPOFile.Add: gfx_constants:rsok | OK | Goed
TPOFile.Add: gfx_constants:rscancel | Cancel | Kanselleer
Then in TPOFile.Translate() the identifer has a '.' delimiter. No
wonder the hash lookup never succeeds!
TPOFile.Translate: gfx_constants.rslanguage | English
identifier failed, trying original value
TPOFile.Translate: gfx_constants.rsok | OK
identifier failed, trying original value
Attached is a patch that fixes this problem in translations.pas unit.
In TPOFile.Translate() I simply replace the first '.' with a ':'
character. The Identifier lookup now succeeds.
The resourcestring identifier from the *.rst files get modified by
'rstconv' program when you generate *.po files. I'm not really sure
which one is at fault.
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
Index: lcl/translations.pas
===================================================================
--- lcl/translations.pas (revision 14167)
+++ lcl/translations.pas (working copy)
@@ -319,8 +319,10 @@
function TPOFile.Translate(const Identifier, OriginalValue: String): String;
var
Item: TPOFileItem;
+ lNewIdentifier: string;
begin
- Item:=TPOFileItem(FIdentifierToItem.Data[Identifier]);
+ lNewIdentifier := StringReplace(Identifier, '.', ':', []);
+ Item:=TPOFileItem(FIdentifierToItem.Data[lNewIdentifier]);
if Item=nil then
Item:=TPOFileItem(FOriginalToItem.Data[OriginalValue]);
if Item<>nil then begin
_______________________________________________
Lazarus mailing list
[email protected]
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus