-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo-mojox-via-inheritance.monkey2
More file actions
105 lines (71 loc) · 1.82 KB
/
Copy pathdemo-mojox-via-inheritance.monkey2
File metadata and controls
105 lines (71 loc) · 1.82 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Namespace jentos.locale.demo.mojox
#Import "<std>"
#Import "<mojo>"
#Import "<mojox>"
#Import "Localization"
#Import "assets/"
Using std..
Using mojo..
Using mojox..
Using jentos.locale
Function Main()
' we can load single file format
'
Locale.Load( "asset::translation.json","en" )
' or directory format
'
'Locale.Load( "asset::locale/","en" )
New AppInstance
New MyWindow
App.Run()
End
Class MyWindow Extends Window
Method New()
Super.New( "",640,480,WindowFlags.Resizable )
' you'll find LocLabel and LocButton below
'
Local docker:=New DockingView
docker.AddView( Localized( "hello-world",New LocLabel ),"top" )
docker.AddView( New Label( "" ),"top" )
docker.AddView( Localized( "button-remove",New LocButton ),"top" )
docker.AddView( New Label( "" ),"top" )
docker.AddView( Localized( "button-close",New LocButton ),"top" )
docker.AddView( New Label( "" ),"top" )
Local switch:=Localized( "switch-lang",New LocButton )
switch.Clicked=Lambda()
' switch lang
Local lang:=Locale.Lang="en" ? "ru" Else "en"
Locale.SetLang( lang )
End
docker.AddView( switch,"top" )
docker.AddView( New Label( "" ),"top" )
ContentView=docker
' update window title via lambda-binding
Localized( "app-title", Self.Localize )
End
Method Localize( t:String )
Title=t
End
End
' implement Localize method to have auto-localization
' when lang will be changed
'
Class LocButton Extends Button
Method New( text:String="",icon:Image=Null )
Super.New( text,icon )
End
Method Localize( t:String )
Text=t
End
End
' implement Localize method to have auto-localization
' when lang will be changed
'
Class LocLabel Extends Label
Method New( text:String="",icon:Image=Null )
Super.New( text,icon )
End
Method Localize( t:String )
Text=t
End
End