[468] | 1 | //**********************************************************************************************************************
|
---|
| 2 | // $Id: Main.pas,v 1.7 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, Dialogs, TntForms,
|
---|
| 13 | StdCtrls, DKLang, 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 | procedure TfMain.cbLanguageChange(Sender: TObject);
|
---|
| 33 | var iIndex: Integer;
|
---|
| 34 | begin
|
---|
| 35 | iIndex := cbLanguage.ItemIndex;
|
---|
| 36 | if iIndex<0 then iIndex := 0; // When there's no valid selection in cbLanguage we use the default language (Index=0)
|
---|
| 37 | LangManager.LanguageID := LangManager.LanguageIDs[iIndex];
|
---|
| 38 | end;
|
---|
| 39 |
|
---|
| 40 | procedure TfMain.FormCreate(Sender: TObject);
|
---|
| 41 | var i: Integer;
|
---|
| 42 | begin
|
---|
| 43 | // Scan for language files in the app directory and register them in the LangManager object
|
---|
| 44 | LangManager.ScanForLangFiles(WideExtractFileDir(WideParamStr(0)), '*.lng', False);
|
---|
| 45 | // Fill cbLanguage with available languages
|
---|
| 46 | for i := 0 to LangManager.LanguageCount-1 do cbLanguage.Items.Add(LangManager.LanguageNames[i]);
|
---|
| 47 | // Index=0 always means the default language
|
---|
| 48 | cbLanguage.ItemIndex := 0;
|
---|
| 49 | end;
|
---|
| 50 |
|
---|
| 51 | end.
|
---|