LCL: updated example for translating the lcl

git-svn-id: trunk@16073 -
This commit is contained in:
mattias 2008-08-15 15:10:40 +00:00
parent 691dd09934
commit e019d42047

View File

@ -32,18 +32,30 @@
Example 2: Load the current language file using the GetLanguageIDs function Example 2: Load the current language file using the GetLanguageIDs function
of the gettext unit: of the gettext unit in the project lpr file:
procedure TForm1.FormCreate(Sender: TObject); uses
...
Translations, gettext;
procedure TranslateLCL;
var var
PODirectory, Lang, FallbackLang: String; PODirectory, Lang, FallbackLang: String;
begin begin
PODirectory:='/path/to/lazarus/lcl/languages/'; PODirectory:='/path/to/lazarus/lcl/languages/';
Lang:='';
FallbackLang:='';
GetLanguageIDs(Lang,FallbackLang); // in unit gettext GetLanguageIDs(Lang,FallbackLang); // in unit gettext
TranslateUnitResourceStrings('LCLStrConsts',PODirectory+'lcl.%s.po', Translations.TranslateUnitResourceStrings('LCLStrConsts',
Lang,FallbackLang); PODirectory+'lclstrconsts.%s.po',Lang,FallbackLang);
MessageDlg('Title','Text',mtInformation,[mbOk,mbCancel,mbYes],0);
end; end;
begin
TranslateLCL;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
} }
unit Translations; unit Translations;
@ -311,7 +323,7 @@ var
po: TPOFile; po: TPOFile;
begin begin
Result:=false; Result:=false;
//debugln('TranslateUnitResourceStrings) ResUnitName="',ResUnitName,'" AFilename="',AFilename,'"'); debugln('TranslateUnitResourceStrings) ResUnitName="',ResUnitName,'" AFilename="',AFilename,'"');
if (ResUnitName='') or (AFilename='') or (not FileExists(AFilename)) then if (ResUnitName='') or (AFilename='') or (not FileExists(AFilename)) then
exit; exit;
try try