root/trunk/max-genlive/gfxboot/dia_lang.inc @ 235

Revision 235, 4.4 KB (checked in by max, 19 months ago)

mario.izquierdo
max-genlive (4.0.max0.46)

  • Update gfxboot-theme-ubuntu package (0.5.20)
    • Better language support
Line 
1% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2%
3% Language selection dialog.
4%
5% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6
7
8% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9% Some global vars.
10%
11
12% fallback if there is no "langlist"
13/lang.items [ "en" ] def
14/lang.names [ "English" ] def
15/lang.displayed false def
16
17/.la.language 0 def
18/.la.locale   1 def
19/.la.name     2 def
20
21
22% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
23% Get language name.
24%
25% Returns locale if not found.
26%
27% ( locale ) ==> ( name )
28%
29/lang.getdefname {
30  lang.defaultnames {
31    dup .la.language get 2 index eq { .la.name get exch pop exit } { pop } ifelse
32  } forall
33} def
34
35
36% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
37% Get locale code (ll_CC).
38%
39% Returns locale if not found.
40%
41% ( locale ) ==> ( ll_CC )
42%
43/lang.getlocale {
44  lang.defaultnames {
45    dup .la.language get 2 index eq { .la.locale get exch pop exit } { pop } ifelse
46  } forall
47} def
48
49
50% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
51% Parse "langlist" file.
52%
53% ( ) ==> ( )
54%
55/lang.parsedata {
56  /lang.default 0 def
57
58  "langlist" findfile dup { /lang.data exch def } { pop return } ifelse
59
60  /la.tmp.datalen lang.data length def
61  /la.tmp.str lang.data cvs def
62 
63  la.tmp.datalen 0 eq { return } if
64  la.tmp.str la.tmp.datalen 1 sub get '\n' ne { return } if
65
66  '\n' seteotchar
67
68  /lang.items [
69
70    /la.tmp.len 0 def
71    /la.tmp.cnt 0 def
72    {
73      la.tmp.str la.tmp.len add strdup
74      dup dup length 0 put
75      /la.tmp.len over length 1 add la.tmp.len add def
76
77      dup 0 get '*' eq { 1 add /lang.default la.tmp.cnt def } if
78
79      la.tmp.len la.tmp.datalen ge { exit } if
80
81      /la.tmp.cnt inc
82    } loop
83
84  ] def
85
86  ' ' seteotchar
87
88  /lang.names [
89
90    lang.items {
91
92      dup dup length add
93
94      dup 0 get {
95        dup 0 0 put 1 add
96        exch pop
97      } {
98        pop lang.getdefname
99      } ifelse
100
101    } forall
102
103  ] def
104
105  0 seteotchar
106
107} def
108
109
110% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
111% Build language list.
112%
113% ( ) ==> ( )
114%
115/lang.init {
116  /xmenu.lang .xm_size array def
117  /xmenu xmenu.lang def
118
119  lang.parsedata
120
121  xmenu .xm_current lang.default put
122  xmenu .xm_list lang.names put
123
124  xmenu .xm_title /txt_language put
125
126  % make menu smaller if there are more than 19 language entries
127  %lang.items length 19 gt {
128  %  xmenu .xm_vspace 2 put
129  %} if
130
131  % start with current lang
132
133  /la.tmp.found false def
134
135  /la.tmp.cnt 0 def
136  lang.items {
137    config.lang eq {
138      xmenu .xm_current la.tmp.cnt put /la.tmp.found true def exit
139    } if
140    /la.tmp.cnt inc
141  } forall
142
143  la.tmp.found not {
144    % Try without the country code.
145    config.lang "_" strstr dup 0 ne {
146      1 sub
147      config.lang strdup dup rot 0 put
148      /la.tmp.cnt 0 def
149      lang.items {
150        over eq {
151          xmenu .xm_current la.tmp.cnt put exit
152        } if
153        /la.tmp.cnt inc
154      } forall
155      free
156    } {
157      pop
158    } ifelse
159  } if
160
161  pmenu.init
162} def
163
164
165% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
166% Update language.
167%
168% ( ) ==> ( )
169%
170/lang.update {
171  /xmenu xmenu.lang def
172
173  lang.items xmenu .xm_current get get
174  dup
175  setlang { /window.action actRedraw def } if
176  setkeymap
177  keymap.langchanged
178
179  window.action actRedraw eq { pmenu.update } if
180} def
181
182
183% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
184% Clean up after language menu has been undrawn.
185%
186% ( ) => ( )
187%
188/lang.cleanup {
189  lang.displayed not {
190    boot.show not {
191      boot.pos moveto boot.label.len neg 0 rmoveto
192      txt_modes_help show
193    } if
194    /lang.displayed true def
195  } if
196} def
197
198
199% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
200% Show language menu.
201%
202% ( ) => ( )
203%
204/panel.lang {
205  "keytable" help.setcontext
206
207  window.xmenu
208  dup .xmenu xmenu.lang put
209  dup .xmenu.update /lang.update put
210  dup .xmenu.cleanup /lang.cleanup put
211  dup window.init
212      window.show
213} def
214
215
216% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
217% Return width of panel entry.
218%
219% ( ) => ( width )
220%
221/panel.lang.width {
222  /xmenu xmenu.lang def
223
224  pmenu.width
225} def
226
227
228% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
229% Redraw panel entry.
230%
231% ( panel ) => ( )
232%
233/panel.lang.update {
234  /xmenu xmenu.lang def
235
236  pmenu.panel.update
237} def
238
239
Note: See TracBrowser for help on using the browser.