[Lazarus] TPOFile.Translate always fails on the Identifier lookup

Graeme Geldenhuys graemeg.lists at gmail.com
Sat Mar 1 20:27:08 CET 2008

On 01/03/2008, Graeme Geldenhuys <graemeg.lists at gmail.com> 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.

  - Graeme -

fpGUI - a cross-platform Free Pascal GUI toolkit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: translations.diff
Type: text/x-patch
Size: 628 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20080301/bf356eaa/attachment-0007.bin>

More information about the Lazarus mailing list