Hi,
I know this is not directly related to Lazarus, but I thought with all the experience collected and that Lazarus supports localization, I might get some good ideas here...
I want to localize the fpGUI toolkit. Standard dialogs, error messages, etc... What is the best way to approach this.
1) GetText: This was my first thought, but that means every fpGUI based application needs to ship with external .po files which I don't like and don't want. fpGUI based applications must preferably be a single works great for your own
applications, but not for the GUI framework I think.
2) Include files with Constants. This is what I'm starting with for now. A gfx_constants.pas unit with $Defines for each supported language. Depending on which define you have active, it will pull in the correct language .inc file with resource strings. If no define has been specified, it defaults to English. This obviously happens at compile time, but at least we have no external files to ship with a simple one file fpGUI based application. The only down side is when you add a new constant, you must remember to insert it into all the other language .inc files - though I'm sure I can create some tool to automate this.
eg:
----------------[ gfx_constants.pas ]--------------------- ....
resourcestring
{ Define Compiler language symbol (eg: gr for German) to include the correct language resource file otherwise the Default (English) resource file will be used. }
{.$DEFINE gr} // German
{.$DEFINE ru} // Russian
{.$DEFINE fr} // French
{.$DEFINE pt} // Portuguese
{$IF defined(gr)}
{$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}
{$ELSE}
{$I lang_english.inc}
{$IFEND}
....
----------------[ end ]--------------------Example language include file:
------------[ lang_english.inc ]-------------
{%mainunit gfx_constants.pas}
rsLanguage = 'English';
// Buttons
rsOK = 'OK';
rsCancel = 'Cancel';
rsHelp = 'Help';
...
--------------[ end ]--------------------3) ???? Anybody got any other ideas? Remember, this is localization for a Toolkit, not for a application. GetText works perfectly for a application.
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
