unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//獲取系統支持的語言列表
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
Memo1.Clear;
for i := 0 to Languages.Count - 1 do
Memo1.Lines.Add(Format('%d: %s', [i, Languages.Name[i]]));
end;
//獲取系統支持語言的 Ext 列表
procedure TForm1.Button2Click(Sender: TObject);
var
i: Integer;
begin
Memo1.Clear;
for i := 0 to Languages.Count - 1 do
Memo1.Lines.Add(Languages.Ext[i] + #9 + Languages.Name[i]);
end;
//系統默認的語言 ID 和在語言列表中的排序
procedure TForm1.Button3Click(Sender: TObject);
var
LangID: Word;
N: Integer;
begin
LangID := GetUserDefaultLangID;
N := Languages.IndexOf(LangID);
ShowMessageFmt('當前語言ID: %d; 在列表中的排序: %d', [LangID, N]);
{當前語言ID: 2052; 在列表中67的排序: %d}
end;
//其他
procedure TForm1.Button4Click(Sender: TObject);
var
s: string;
begin
ShowMessage(Languages.ID[67]); //$00000804
ShowMessage(IntToStr(Languages.LocaleID[67])); //2052
ShowMessage(Languages.NameFromLCID['2052']); //中文(中國)
ShowMessage(Languages.NameFromLocaleID[2052]); //中文(中國)
ShowMessage(GetUILanguages(2052)); // zh-CN,zh-Hans,zh
ShowMessage(PreferredUILanguages); // ZH-CN,ZH-HANS,ZH
for s in PreferredUILanguageList do ShowMessage(s); //ZH-CN ...
end;