XE3随笔21:系统默认语言与系统支持的语言列表

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 := to Languages.Count - 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 := to Languages.Count - 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[]);                  //$00000804
  ShowMessage(IntToStr(Languages.LocaleID[]));  //2052   ShowMessage(Languages.NameFromLCID['2052']);    //中文(中国)
  ShowMessage(Languages.NameFromLocaleID[]);  //中文(中国)   ShowMessage(GetUILanguages()); // zh-CN,zh-Hans,zh
  ShowMessage(PreferredUILanguages); // ZH-CN,ZH-HANS,ZH   for s in PreferredUILanguageList do ShowMessage(s); //ZH-CN ...
end; end.
上一篇:Android开发 :androidstudio device offline


下一篇:DDOS的攻击原理和防护指南