From e019d42047c409c72da3a9f48a223fe63176f15f Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 15 Aug 2008 15:10:40 +0000 Subject: [PATCH] LCL: updated example for translating the lcl git-svn-id: trunk@16073 - --- lcl/translations.pas | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lcl/translations.pas b/lcl/translations.pas index e2b0349914..188ddf8b54 100644 --- a/lcl/translations.pas +++ b/lcl/translations.pas @@ -32,18 +32,30 @@ Example 2: Load the current language file using the GetLanguageIDs function - of the gettext unit: - - procedure TForm1.FormCreate(Sender: TObject); + of the gettext unit in the project lpr file: + + uses + ... + Translations, gettext; + + procedure TranslateLCL; var PODirectory, Lang, FallbackLang: String; begin PODirectory:='/path/to/lazarus/lcl/languages/'; + Lang:=''; + FallbackLang:=''; GetLanguageIDs(Lang,FallbackLang); // in unit gettext - TranslateUnitResourceStrings('LCLStrConsts',PODirectory+'lcl.%s.po', - Lang,FallbackLang); - MessageDlg('Title','Text',mtInformation,[mbOk,mbCancel,mbYes],0); + Translations.TranslateUnitResourceStrings('LCLStrConsts', + PODirectory+'lclstrconsts.%s.po',Lang,FallbackLang); end; + + begin + TranslateLCL; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; + end. } unit Translations; @@ -311,7 +323,7 @@ var po: TPOFile; begin Result:=false; - //debugln('TranslateUnitResourceStrings) ResUnitName="',ResUnitName,'" AFilename="',AFilename,'"'); + debugln('TranslateUnitResourceStrings) ResUnitName="',ResUnitName,'" AFilename="',AFilename,'"'); if (ResUnitName='') or (AFilename='') or (not FileExists(AFilename)) then exit; try