blob: 16995dec5a9be03e50cc84999f9fe98a1c19c002 (
plain)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
% Language selection dialog.
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Some global vars.
%
% fallback if there is no "languages"
/lang.items [ "en" ] def
/lang.names [ "English" ] def
/.la.locale 0 def
/.la.name 1 def
/lang.defaultnames [
% [ "ar" "\u064a\u0628\u0631\u0639" ]
[ "ar" "\ufef2\ufe91\ufeae\ufecb" ]
[ "bn" "Bengali" ]
[ "bs" "Bosanski" ]
[ "bg" "Български" ]
[ "cs" "Čeština" ]
[ "cy_GB" "Cymraeg" ]
[ "da" "Dansk" ]
[ "en" "English" ]
[ "fr" "Français" ]
[ "de" "Deutsch" ]
[ "es" "Español" ]
[ "el" "Ελληνικά" ]
[ "fi" "Suomi" ]
[ "he" "תירבע" ]
[ "it" "Italiano" ]
[ "ja" "日本語" ]
[ "hi" "Hindi" ]
[ "hr" "Hrvatski" ]
[ "hu" "Magyar" ]
[ "km_KH" "Khmer" ]
[ "ko" "한글" ]
[ "lt" "Lietuvių" ]
[ "nl" "Nederlands" ]
[ "nb" "Norsk (bokmål)" ]
[ "nn" "Norsk (nynorsk)" ]
[ "pl" "Polski" ]
[ "pt_PT" "Português" ]
[ "pt_BR" "Português (Brasil)" ]
[ "pa" "Punjabi" ]
[ "ro" "Română" ]
[ "ru" "Русский" ]
[ "sk" "Slovenčina" ]
[ "sl" "Slovenščina" ]
[ "sr" "Cрпски" ]
[ "sv" "Svenska" ]
[ "tr" "Türkçe" ]
[ "uk" "Українська" ]
[ "zh_CN" "简体中文" ]
[ "zh_TW" "繁體中文 (台灣)" ]
] def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Get language name.
%
% Returns locale if not found.
%
% ( locale ) ==> ( name )
%
/lang.getdefname {
lang.defaultnames {
dup .la.locale get 2 index eq { .la.name get exch pop exit } { pop } ifelse
} forall
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Parse "languages" file.
%
% ( ) ==> ( )
%
/lang.parsedata {
/lang.default 0 def
"langs" findfile dup { /lang.data exch def } { pop return } ifelse
/la.tmp.datalen lang.data length def
/la.tmp.str lang.data cvs def
la.tmp.datalen 0 eq { return } if
la.tmp.str la.tmp.datalen 1 sub get '\n' ne { return } if
'\n' seteotchar
/lang.items [
/la.tmp.len 0 def
/la.tmp.cnt 0 def
{
la.tmp.str la.tmp.len add strdup
dup dup length 0 put
/la.tmp.len over length 1 add la.tmp.len add def
dup 0 get '*' eq { 1 add /lang.default la.tmp.cnt def } if
la.tmp.len la.tmp.datalen ge { exit } if
/la.tmp.cnt inc
} loop
] def
' ' seteotchar
/lang.names [
lang.items {
dup dup length add
dup 0 get {
dup 0 0 put 1 add
exch pop
} {
pop lang.getdefname
} ifelse
} forall
] def
0 seteotchar
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Build language list.
%
% ( ) ==> ( )
%
/lang.init {
/xmenu.lang .xm_size array def
/xmenu xmenu.lang def
lang.parsedata
xmenu .xm_current lang.default put
xmenu .xm_list lang.names put
xmenu .xm_title /txt_language put
% make menu smaller if there are more than 19 language entries
%lang.items length 19 gt {
% xmenu .xm_vspace 2 put
%} if
% start with current lang
/la.tmp.cnt 0 def
lang.items {
config.lang eq { xmenu .xm_current la.tmp.cnt put exit } if
/la.tmp.cnt inc
} forall
pmenu.init
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Update language.
%
% ( ) ==> ( )
%
/lang.update {
/xmenu xmenu.lang def
lang.items xmenu .xm_current get get
dup
setlang { /window.action actRedraw def } if
setkeymap
% Why? --> see dia_install.inc; same there.
window.action actRedraw eq { pmenu.update } if
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Show language menu.
%
% ( ) => ( )
%
/panel.lang {
"keytable" help.setcontext
window.xmenu
dup .xmenu xmenu.lang put
dup .xmenu.update /lang.update put
dup window.init
window.show
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Return width of panel entry.
%
% ( ) => ( width )
%
/panel.lang.width {
/xmenu xmenu.lang def
pmenu.width
} def
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Redraw panel entry.
%
% ( panel ) => ( )
%
/panel.lang.update {
/xmenu xmenu.lang def
pmenu.panel.update
} def
|