-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathuLangModule.pas
More file actions
59 lines (45 loc) · 1.09 KB
/
Copy pathuLangModule.pas
File metadata and controls
59 lines (45 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
unit uLangModule;
interface
uses
System.SysUtils
, System.Classes
, FMX.Menus
, FMX.Types;
type
TmoduleLang = class(TDataModule)
langJa: TLang;
private class var
FInstance: TmoduleLang;
private
class constructor CreateClass;
class destructor DestroyClass;
public
class procedure SetLangToMenu(const iMenu: TPopupMenu);
end;
implementation
{%CLASSGROUP 'FMX.Controls.TControl'}
{$R *.dfm}
{ TmoduleLang }
class constructor TmoduleLang.CreateClass;
begin
FInstance := TmoduleLang.Create(nil);
end;
class destructor TmoduleLang.DestroyClass;
begin
FInstance.Free;
end;
class procedure TmoduleLang.SetLangToMenu(const iMenu: TPopupMenu);
procedure TranslateMenuText(const iMenuItem: TMenuItem);
begin
var Str := Translate(iMenuItem.Text);
//var Str := FInstance.langJa.LangStr[iMenuItem.Text];
if (Str.Length > 0) then
iMenuItem.Text := Str;
for var i := 0 to iMenuItem.ItemsCount - 1 do
TranslateMenuText(iMenuItem.Items[i]);
end;
begin
for var i := 0 to iMenu.ItemsCount - 1 do
TranslateMenuText(iMenu.Items[i]);
end;
end.