| 1 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 2 |
% |
|---|
| 3 |
% Language selection dialog. |
|---|
| 4 |
% |
|---|
| 5 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 9 |
% Some global vars. |
|---|
| 10 |
% |
|---|
| 11 |
|
|---|
| 12 |
% fallback if there is no "languages" |
|---|
| 13 |
/lang.items [ "en" ] def |
|---|
| 14 |
/lang.names [ "English" ] def |
|---|
| 15 |
|
|---|
| 16 |
/.la.locale 0 def |
|---|
| 17 |
/.la.name 1 def |
|---|
| 18 |
/lang.defaultnames [ |
|---|
| 19 |
[ "cs" "\u010ce\u0161tina" ] |
|---|
| 20 |
[ "en" "English" ] |
|---|
| 21 |
[ "fr" "Fran\u00e7ais" ] |
|---|
| 22 |
[ "de" "Deutsch" ] |
|---|
| 23 |
[ "es" "Espa\u00f1ol" ] |
|---|
| 24 |
[ "it" "Italiano" ] |
|---|
| 25 |
[ "ja" "\u65e5\u672c\u8a9e" ] |
|---|
| 26 |
[ "hu" "Magyar" ] |
|---|
| 27 |
[ "nl" "Nederlands" ] |
|---|
| 28 |
[ "ro" "Romanian" ] |
|---|
| 29 |
[ "ru" "\u0420\u0443\u0441\u0441\u043a\u0438\u0439" ] |
|---|
| 30 |
[ "sk" "Sloven\u010dina" ] |
|---|
| 31 |
[ "sl" "Sloven\u0161\u010dina" ] |
|---|
| 32 |
[ "sv" "Svenska" ] |
|---|
| 33 |
] def |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 37 |
% Get language name. |
|---|
| 38 |
% |
|---|
| 39 |
% Returns locale if not found. |
|---|
| 40 |
% |
|---|
| 41 |
% ( locale ) ==> ( name ) |
|---|
| 42 |
% |
|---|
| 43 |
/lang.getdefname { |
|---|
| 44 |
lang.defaultnames { |
|---|
| 45 |
dup .la.locale get 2 index eq { .la.name get exch pop exit } { pop } ifelse |
|---|
| 46 |
} forall |
|---|
| 47 |
} def |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 51 |
% Parse "languages" file. |
|---|
| 52 |
% |
|---|
| 53 |
% ( ) ==> ( ) |
|---|
| 54 |
% |
|---|
| 55 |
/lang.parsedata { |
|---|
| 56 |
/lang.default 0 def |
|---|
| 57 |
|
|---|
| 58 |
"languages" 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 |
dup |
|---|
| 92 |
|
|---|
| 93 |
dup length add |
|---|
| 94 |
dup 0 0 put |
|---|
| 95 |
1 add |
|---|
| 96 |
|
|---|
| 97 |
dup "" ne { exch pop } { pop lang.getdefname } ifelse |
|---|
| 98 |
|
|---|
| 99 |
} forall |
|---|
| 100 |
|
|---|
| 101 |
] def |
|---|
| 102 |
|
|---|
| 103 |
0 seteotchar |
|---|
| 104 |
|
|---|
| 105 |
} def |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 109 |
% Build language list. |
|---|
| 110 |
% |
|---|
| 111 |
% ( ) ==> ( ) |
|---|
| 112 |
% |
|---|
| 113 |
/lang.init { |
|---|
| 114 |
/xmenu.lang .xm_size array def |
|---|
| 115 |
/xmenu xmenu.lang def |
|---|
| 116 |
|
|---|
| 117 |
lang.parsedata |
|---|
| 118 |
|
|---|
| 119 |
xmenu .xm_current lang.default put |
|---|
| 120 |
xmenu .xm_list lang.names put |
|---|
| 121 |
|
|---|
| 122 |
% start with current lang |
|---|
| 123 |
|
|---|
| 124 |
/la.tmp.cnt 0 def |
|---|
| 125 |
lang.items { |
|---|
| 126 |
config.lang eq { xmenu .xm_current la.tmp.cnt put exit } if |
|---|
| 127 |
/la.tmp.cnt inc |
|---|
| 128 |
} forall |
|---|
| 129 |
|
|---|
| 130 |
pmenu.init |
|---|
| 131 |
} def |
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 135 |
% Update language. |
|---|
| 136 |
% |
|---|
| 137 |
% ( ) ==> ( ) |
|---|
| 138 |
% |
|---|
| 139 |
/lang.update { |
|---|
| 140 |
/xmenu xmenu.lang def |
|---|
| 141 |
|
|---|
| 142 |
lang.items xmenu .xm_current get get |
|---|
| 143 |
dup |
|---|
| 144 |
setlang { /window.action actRedraw def } if |
|---|
| 145 |
setkeymap |
|---|
| 146 |
|
|---|
| 147 |
% Why? --> see dia_install.inc; same there. |
|---|
| 148 |
window.action actRedraw eq { pmenu.update } if |
|---|
| 149 |
/window.action actRedrawPanel def |
|---|
| 150 |
} def |
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 154 |
% Show language menu. |
|---|
| 155 |
% |
|---|
| 156 |
% ( ) => ( ) |
|---|
| 157 |
% |
|---|
| 158 |
/panel.lang { |
|---|
| 159 |
"keytable" help.setcontext |
|---|
| 160 |
|
|---|
| 161 |
window.xmenu |
|---|
| 162 |
dup .xmenu xmenu.lang put |
|---|
| 163 |
dup .xmenu.update /lang.update put |
|---|
| 164 |
dup window.init |
|---|
| 165 |
window.show |
|---|
| 166 |
} def |
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 170 |
% Return width of panel entry. |
|---|
| 171 |
% |
|---|
| 172 |
% ( ) => ( width ) |
|---|
| 173 |
% |
|---|
| 174 |
/panel.lang.width { |
|---|
| 175 |
/xmenu xmenu.lang def |
|---|
| 176 |
|
|---|
| 177 |
pmenu.width |
|---|
| 178 |
} def |
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 182 |
% Redraw panel entry. |
|---|
| 183 |
% |
|---|
| 184 |
% ( panel ) => ( ) |
|---|
| 185 |
% |
|---|
| 186 |
/panel.lang.update { |
|---|
| 187 |
/xmenu xmenu.lang def |
|---|
| 188 |
|
|---|
| 189 |
pmenu.panel.update |
|---|
| 190 |
} def |
|---|
| 191 |
|
|---|
| 192 |
|
|---|