⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wplocalu.pas

📁 wptools5 pro 完整源代码 Msword界面的文本编辑器源代码
💻 PAS
字号:
unit WPLocalU;

interface

uses
  SysUtils, Classes, Dialogs, Controls, Forms, Menus, WPLngCtr, WPXMLint,
  WPUtil, WPActnStr, wpDefActions;

type
  TWPLocalisationDataModule = class(TDataModule)
    WPLanguageControl1: TWPLanguageControl;
    procedure DataModuleCreate(Sender: TObject);
    procedure DataModuleDestroy(Sender: TObject);
  private
    Popup : TPopupMenu;
    procedure SelLanguageClick(Sender : TObject);
  public
    WPDefAct : TWPDefAct;
    procedure SelectLanguage(Sender : TObject);
  end;

var
  WPLocalisationDataModule: TWPLocalisationDataModule;

implementation

{$R *.dfm}

procedure TWPLocalisationDataModule.DataModuleCreate(Sender: TObject);
begin
   Popup := TPopupMenu.Create(Self);
   // attach localization
   WPLangInterface := TWPLocalizationInterface.Create(WPLanguageControl1);
end;

procedure TWPLocalisationDataModule.DataModuleDestroy(Sender: TObject);
begin
  Popup.Free;
  WPLangInterface.Free;
  // detach localization
  WPLangInterface := nil;
end;

procedure TWPLocalisationDataModule.SelectLanguage(Sender : TObject);
var i : Integer;
    loc : TWPXMLOneLevel;
    men : TMenuItem;
begin
    Popup.Items.Clear;
    loc := WPLanguageControl1.Find('/loc');
    Popup.Items.Clear;
    if loc=nil then
       ShowMessage('The information in WPLanguageControl1 has no branch "/loc"')
    else for i:=0 to loc.Count-1 do
    begin
        men := TMenuItem.Create(Popup);
        Popup.Items.Add(men);
        men.Caption := loc[i].Name;
        men.OnClick := SelLanguageClick;
    end;
    Popup.Popup(Mouse.CursorPos.x, Mouse.CursorPos.y);
end;

// Set the language name (DE, FR ...) and then load the strings
procedure TWPLocalisationDataModule.SelLanguageClick(Sender : TObject);
begin
  WPLanguageControl1.GlobalLanguage :=
     (Sender as TMenuItem).Caption;
  WPLocalizeLoadForms := TRUE;
  WPTools_LoadVCLStrings;    // WPUtils
  WPTools_LoadActionStrings; // WPActnStr
  if WPDefAct<>nil then WPDefAct.LoadStrings;
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -