[468] | 1 | //**********************************************************************************************************************
|
---|
| 2 | // $Id: Main.pas,v 1.4 2006/08/11 12:15:51 dale Exp $
|
---|
| 3 | //----------------------------------------------------------------------------------------------------------------------
|
---|
| 4 | // DKLang Localization Package
|
---|
| 5 | // Copyright (c)DK Software, http://www.dk-soft.org/
|
---|
| 6 | //**********************************************************************************************************************
|
---|
| 7 | unit Main;
|
---|
| 8 |
|
---|
| 9 | interface
|
---|
| 10 |
|
---|
| 11 | uses
|
---|
| 12 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, TntForms,
|
---|
| 13 | Dialogs, DKLang, StdCtrls, TntStdCtrls;
|
---|
| 14 |
|
---|
| 15 | type
|
---|
| 16 | TfMain = class(TTntForm)
|
---|
| 17 | bCancel: TTntButton;
|
---|
| 18 | cbLanguage: TTntComboBox;
|
---|
| 19 | lcMain: TDKLanguageController;
|
---|
| 20 | lSampleMessage: TTntLabel;
|
---|
| 21 | procedure cbLanguageChange(Sender: TObject);
|
---|
| 22 | procedure FormCreate(Sender: TObject);
|
---|
| 23 | end;
|
---|
| 24 |
|
---|
| 25 | var
|
---|
| 26 | fMain: TfMain;
|
---|
| 27 |
|
---|
| 28 | implementation
|
---|
| 29 | {$R *.dfm}
|
---|
| 30 | uses TntSystem, TntSysUtils;
|
---|
| 31 |
|
---|
| 32 | {$R LangFiles.res} // Notice this resource inclusion!
|
---|
| 33 |
|
---|
| 34 | procedure TfMain.cbLanguageChange(Sender: TObject);
|
---|
| 35 | var iIndex: Integer;
|
---|
| 36 | begin
|
---|
| 37 | iIndex := cbLanguage.ItemIndex;
|
---|
| 38 | if iIndex<0 then iIndex := 0; // When there's no valid selection in cbLanguage we use the default language (Index=0)
|
---|
| 39 | LangManager.LanguageID := LangManager.LanguageIDs[iIndex];
|
---|
| 40 | end;
|
---|
| 41 |
|
---|
| 42 | procedure TfMain.FormCreate(Sender: TObject);
|
---|
| 43 | var i: Integer;
|
---|
| 44 | begin
|
---|
| 45 | // Fill in the 'statically included' languages
|
---|
| 46 | LangManager.RegisterLangResource(HInstance, 'LNG_RUSSIAN', 1049);
|
---|
| 47 | LangManager.RegisterLangResource(HInstance, 'LNG_GERMAN', 1031);
|
---|
| 48 | // Additionally, you can scan for language files in the app directory, uncomment the next line to do this
|
---|
| 49 | //LangManager.ScanForLangFiles(WideExtractFileDir(WideParamStr(0)), '*.lng', False);
|
---|
| 50 | // Fill cbLanguage with available languages
|
---|
| 51 | for i := 0 to LangManager.LanguageCount-1 do cbLanguage.Items.Add(LangManager.LanguageNames[i]);
|
---|
| 52 | // Index=0 always means the default language
|
---|
| 53 | cbLanguage.ItemIndex := 0;
|
---|
| 54 | end;
|
---|
| 55 |
|
---|
| 56 | end.
|
---|