1 | //**********************************************************************************************************************
|
---|
2 | // $Id: Main.pas,v 1.8 2006/08/11 12:15:50 dale Exp $
|
---|
3 | //----------------------------------------------------------------------------------------------------------------------
|
---|
4 | // DKLang Localization Package
|
---|
5 | // Copyright 2002-2006 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 | DKLang, StdCtrls, TntStdCtrls;
|
---|
14 |
|
---|
15 | type
|
---|
16 | TfMain = class(TTntForm)
|
---|
17 | bTest: TTntButton;
|
---|
18 | cbLanguage: TTntComboBox;
|
---|
19 | lcMain: TDKLanguageController;
|
---|
20 | lSampleMessage: TTntLabel;
|
---|
21 | procedure bTestClick(Sender: TObject);
|
---|
22 | procedure cbLanguageChange(Sender: TObject);
|
---|
23 | procedure FormCreate(Sender: TObject);
|
---|
24 | end;
|
---|
25 |
|
---|
26 | var
|
---|
27 | fMain: TfMain;
|
---|
28 |
|
---|
29 | implementation
|
---|
30 | {$R *.dfm}
|
---|
31 | uses TntSystem, TntSysUtils;
|
---|
32 |
|
---|
33 | procedure TfMain.bTestClick(Sender: TObject);
|
---|
34 | begin
|
---|
35 | MessageBoxW(
|
---|
36 | Application.Handle,
|
---|
37 | PWideChar(DKLangConstW('STestMessage')),
|
---|
38 | PWideChar(DKLangConstW('SMessageCaption')),
|
---|
39 | MB_ICONINFORMATION or MB_OK);
|
---|
40 | end;
|
---|
41 |
|
---|
42 | procedure TfMain.cbLanguageChange(Sender: TObject);
|
---|
43 | var iIndex: Integer;
|
---|
44 | begin
|
---|
45 | iIndex := cbLanguage.ItemIndex;
|
---|
46 | if iIndex<0 then iIndex := 0; // When there's no valid selection in cbLanguage we use the default language (Index=0)
|
---|
47 | LangManager.LanguageID := LangManager.LanguageIDs[iIndex];
|
---|
48 | end;
|
---|
49 |
|
---|
50 | procedure TfMain.FormCreate(Sender: TObject);
|
---|
51 | var i: Integer;
|
---|
52 | begin
|
---|
53 | // Scan for language files in the app directory and register them in the LangManager object
|
---|
54 | LangManager.ScanForLangFiles(WideExtractFileDir(WideParamStr(0)), '*.lng', False);
|
---|
55 | // Fill cbLanguage with available languages
|
---|
56 | for i := 0 to LangManager.LanguageCount-1 do cbLanguage.Items.Add(LangManager.LanguageNames[i]);
|
---|
57 | // Index=0 always means the default language
|
---|
58 | cbLanguage.ItemIndex := 0;
|
---|
59 | end;
|
---|
60 |
|
---|
61 | end.
|
---|