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

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Mar 1 20:17:31 CET 2008


On Sat, 1 Mar 2008 20:08:04 +0200
"Graeme Geldenhuys" <graemeg.lists at gmail.com> wrote:

> Hi,
> 
> I'm using LCL's translations.pas unit in fpGUI. I have simply removed
> the LCL specific units from the uses clause and replaced it with FPC
> or fpGUI ones. The actual processing of the POFiles are identical,
> nothing has changed. I have two queries though....
> 
> 1) Why doesn't the translations.pas unit use FPC's standard
> TFPObjectHashTable class, but instead opt for a custom written
> TStringHashList (StringHashList.pas unit)? 

AFAIR TStringHashList existed first.

> What is the benefit of
> using the StringHashList unit?

AFAIK TStringHashList is faster.

 
> 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?

Maybe the russian .po file is buggy?
Uncomment the debugln in TPOFile.Add and see what is added.

 
>[...]
> The standard (runtime loaded) translation files (*.po) was created
> from the original English include file.  Now if I change fpGUI's
> default language to say Russian, the only way to do a successful PO
> lookup is via the resourcestring identifier (eg:
> gfx_constants.rsLanguage), because the original string in the PO files
> are based on the English language.
> 
> Anybody got any clues as to why the FIdentifierToItem.Data[] always
> returns nil? I even replaced the the internal hash class from
> TStringListHash to FPC's TFPObjectHashTable, but the problem still
> persists!
> 
> 
> ----------------------- COPY -------------------------
> function TPOFile.Translate(const Identifier, OriginalValue: String):
> String; var
>   Item: TPOFileItem;
> begin
>   Item:=TPOFileItem(FIdentifierToItem.Data[Identifier]);
>   if Item=nil then
>     Item:=TPOFileItem(FOriginalToItem.Data[OriginalValue]);
>   if Item<>nil then begin
>     Result:=Item.Translation;
>     if Result='' then RaiseGDBException('TPOFile.Translate
> Inconsistency'); end else
>     Result:=OriginalValue;
> end;
> ----------------------- END -------------------------
> 
> 
> If the problem is still not clear, I can try and create a small demo
> project doing exactly what fpGUI does, which will highlight the issue.

That will help.

Mattias



More information about the Lazarus mailing list