系统默认语言与系统支持的语言列表

为什么80%的码农都做不了架构师?>>>   hot3.png


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;

end.

 
 
 
 
 

 

 

  

转载于:https://my.oschina.net/hermer/blog/320538

你可能感兴趣的:(系统默认语言与系统支持的语言列表)