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)? What is the benefit of using the StringHashList unit?
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?
The reason I detected it, is because fpGUI can change it's default compiled language. It uses include files to pull in the correct translation based on a $DEFINE statement. This code is show below...
------------ COPY ---------------
{ Define Compiler language symbol (eg: de for German) to include the correct language resource file otherwise the Default (English) resource file will be used. }
{.$DEFINE de} // German
{.$DEFINE ru} // Russian
{.$DEFINE fr} // French
{.$DEFINE pt} // Portuguese (Brazil)
{.$DEFINE za} // Afrikaans
{.$DEFINE it} // Italian
{$IF defined(de)}
{$I lang_german.inc}
{$ELSEIF defined(ru)}
{$I lang_russian.inc}
{$ELSEIF defined(fr)}
{$I lang_french.inc}
{$ELSEIF defined(pt)}
{$I lang_portuguese.inc}
{$ELSEIF defined(za)}
{$I lang_afrikaans.inc}
{$ELSEIF defined(it)}
{$I lang_italian.inc}
{$ELSE}
{$I lang_english.inc}
{$IFEND}
-------------- END ---------------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 Itemnil 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.
By the way, I'm trying all this under Linux and changing the LANG environment variable.
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
