vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Informant
3 An addon for World of Warcraft that shows pertinent information about
4 an item in a tooltip when you hover over the item in the game.
5 3.8.0 (Kangaroo)
6 $Id: InfCommand.lua 854 2006-05-10 04:23:18Z mentalpower $
7 Command handler. Assumes responsibility for allowing the user to set the
8 options via slash command, Khaos, MyAddon etc.
9  
10 License:
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
15  
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20  
21 You should have received a copy of the GNU General Public License
22 along with this program(see GLP.txt); if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 --]]
25  
26 -- function prototypes
27 local commandHandler, cmdHelp, onOff, genVarSet, chatPrint, registerKhaos, restoreDefault, cmdLocale, setLocale, isValidLocale
28 local setKhaosSetKeyValue
29  
30 -- Localization function prototypes
31 local delocalizeFilterVal, localizeFilterVal, getLocalizedFilterVal, delocalizeCommand, localizeCommand, buildCommandMap
32  
33 local commandMap = nil;
34 local commandMapRev = nil;
35  
36 Informant_Khaos_Registered = nil
37  
38 Informant.InitCommands = function()
39 SLASH_INFORMANT1 = "/informant"
40 SLASH_INFORMANT2 = "/inform"
41 SLASH_INFORMANT3 = "/info"
42 SLASH_INFORMANT4 = "/inf"
43 SlashCmdList["INFORMANT"] = function(msg)
44 commandHandler(msg, nil)
45 end
46  
47 chatPrint(string.format(_INFM('FrmtWelcome'), INFORMANT_VERSION))
48  
49 if (Khaos) then
50 registerKhaos()
51 end
52 end
53  
54 function setKhaosSetKeyValue(key, value)
55 if (Informant_Khaos_Registered) then
56 local kKey = Khaos.getSetKey("Informant", key)
57  
58 if (not kKey) then
59 EnhTooltip.DebugPrint("setKhaosSetKeyParameter(): key " .. key .. " does not exist")
60 elseif (kKey.checked ~= nil) then
61 if (type(value) == "string") then value = (value == "on"); end
62 Khaos.setSetKeyParameter("Informant", key, "checked", value)
63 elseif (kKey.value ~= nil) then
64 Khaos.setSetKeyParameter("Informant", key, "value", value)
65 else
66 EnhTooltip.DebugPrint("setKhaosSetKeyValue(): don't know how to update key ", key)
67 end
68 end
69 end
70  
71 function buildCommandMap()
72 commandMap = {
73 [_INFM('CmdOn')] = 'on',
74 [_INFM('CmdOff')] = 'off',
75 [_INFM('CmdHelp')] = 'help',
76 [_INFM('CmdToggle')] = 'toggle',
77 [_INFM('CmdDisable')] = 'disable',
78 [_INFM('CmdLocale')] = 'locale',
79 [_INFM('CmdDefault')] = 'default',
80 [_INFM('CmdEmbed')] = 'embed',
81 [_INFM('ShowIcon')] = 'show-icon',
82 [_INFM('ShowStack')] = 'show-stack',
83 [_INFM('ShowUsage')] = 'show-usage',
84 [_INFM('ShowQuest')] = 'show-quest',
85 [_INFM('ShowMerchant')] = 'show-merchant',
86 [_INFM('ShowVendor')] = 'show-vendor',
87 [_INFM('ShowVendorBuy')] = 'show-vendor-buy',
88 [_INFM('ShowVendorSell')] = 'show-vendor-sell',
89 }
90  
91 commandMapRev = {}
92 for k,v in pairs(commandMap) do
93 commandMapRev[v] = k;
94 end
95 end
96  
97 --Cleaner Command Handling Functions (added by MentalPower)
98 function commandHandler(command, source)
99 --To print or not to print, that is the question...
100 local chatprint = nil
101 if (source == "GUI") then chatprint = false
102 else chatprint = true end
103  
104 --Divide the large command into smaller logical sections (Shameless copy from the original function)
105 local i,j, cmd, param = string.find(command, "^([^ ]+) (.+)$")
106 if (not cmd) then cmd = command end
107 if (not cmd) then cmd = "" end
108 if (not param) then param = "" end
109 cmd = delocalizeCommand(cmd);
110  
111 --Now for the real Command handling
112 if ((cmd == "") or (cmd == "help")) then
113 cmdHelp()
114 return
115  
116 elseif (cmd == "on" or cmd == "off" or cmd == "toggle") then
117 onOff(cmd, chatprint)
118 elseif (cmd == "disable") then
119 Stubby.SetConfig("Informant", "LoadType", "never");
120 elseif (cmd == "load") then
121 if (param == "always") or (param == "never") then
122 chatPrint("Setting Informant to "..param.." load for this toon");
123 Stubby.SetConfig("Informant", "LoadType", param);
124 end
125 elseif (cmd == "locale") then
126 setLocale(param, chatprint)
127 elseif (cmd == "default") then
128 restoreDefault(param, chatprint)
129 elseif (cmd == "embed" or cmd == "show-stack" or cmd == "show-usage" or
130 cmd == "show-quest" or cmd == "show-merchant" or cmd == "show-vendor" or
131 cmd == "show-vendor-buy" or cmd == "show-vendor-sell" or cmd == "show-icon") then
132 genVarSet(cmd, param, chatprint)
133 else
134 if (chatprint) then
135 chatPrint(string.format(_INFM('FrmtActUnknown'), cmd))
136 end
137 end
138 end
139  
140 --Help ME!! (The Handler) (Another shameless copy from the original function)
141 function cmdHelp()
142  
143 local onOffToggle = " (".._INFM('CmdOn').."|".._INFM('CmdOff').."|".._INFM('CmdToggle')..")"
144 local lineFormat = " |cffffffff/informant %s "..onOffToggle.."|r |cffff4020[%s]|r - %s"
145  
146 chatPrint(_INFM('TextUsage'))
147 chatPrint(" |cffffffff/informant "..onOffToggle.."|r |cffff4020["..getLocalizedFilterVal('all').."]|r - " .. _INFM('HelpOnoff'))
148  
149 chatPrint(" |cffffffff/informant ".._INFM('CmdDisable').."|r - " .. _INFM('HelpDisable'));
150  
151 chatPrint(string.format(lineFormat, _INFM('ShowVendor'), getLocalizedFilterVal('show-vendor'), _INFM('HelpVendor')))
152 chatPrint(string.format(lineFormat, _INFM('ShowVendorSell'), getLocalizedFilterVal('show-vendor-sell'), _INFM('HelpVendorSell')))
153 chatPrint(string.format(lineFormat, _INFM('ShowVendorBuy'), getLocalizedFilterVal('show-vendor-buy'), _INFM('HelpVendorBuy')))
154 chatPrint(string.format(lineFormat, _INFM('ShowUsage'), getLocalizedFilterVal('show-usage'), _INFM('HelpUsage')))
155 chatPrint(string.format(lineFormat, _INFM('ShowMerchant'), getLocalizedFilterVal('show-merchant'), _INFM('HelpMerchant')))
156 chatPrint(string.format(lineFormat, _INFM('ShowStack'), getLocalizedFilterVal('show-stack'), _INFM('HelpStack')))
157 chatPrint(string.format(lineFormat, _INFM('ShowIcon'), getLocalizedFilterVal('show-icon'), _INFM('HelpIcon')))
158 chatPrint(string.format(lineFormat, _INFM('CmdEmbed'), getLocalizedFilterVal('embed'), _INFM('HelpEmbed')))
159  
160 lineFormat = " |cffffffff/informant %s %s|r |cffff4020[%s]|r - %s"
161 chatPrint(string.format(lineFormat, _INFM('CmdLocale'), _INFM('OptLocale'), getLocalizedFilterVal('locale'), _INFM('HelpLocale')))
162  
163 lineFormat = " |cffffffff/informant %s %s|r - %s"
164 chatPrint(string.format(lineFormat, _INFM('CmdDefault'), "", _INFM('HelpDefault')))
165 end
166  
167 --The onOff(state, chatprint) function handles the state of the Informant AddOn (whether it is currently on or off)
168 --If "on" or "off" is specified in the " state" variable then Informant's state is changed to that value,
169 --If "toggle" is specified then it will toggle Informant's state (if currently on then it will be turned off and vice-versa)
170 --If no keyword is specified then the functione will simply return the current state
171 --
172 --If chatprint is "true" then the state will also be printed to the user.
173  
174 function onOff(state, chatprint)
175  
176 if ((state == nil) or (state == "")) then
177 state = Informant.GetFilterVal("all")
178  
179  
180 elseif ((state == _INFM('CmdOn')) or (state == "on")) then
181 Informant.SetFilter("all", "on")
182  
183  
184 elseif ((state == _INFM('CmdOff')) or (state == "off")) then
185 Informant.SetFilter("all", "off")
186  
187  
188 elseif ((state == _INFM('CmdToggle')) or (state == "toggle")) then
189 Informant.SetFilter("all", not Informant.GetFilter("all"))
190 state = Informant.GetFilterVal("all")
191  
192  
193 end
194  
195 --Print the change and alert the GUI if the command came from slash commands. Do nothing if they came from the GUI.
196 if (chatprint == true) then
197 if ((state == _INFM('CmdOn')) or (state == "on")) then
198 chatPrint(_INFM('StatOn'))
199  
200 if (Informant_Khaos_Registered) then
201 Khaos.setSetKeyParameter("Informant", "enabled", "checked", true)
202 end
203 else
204 chatPrint(_INFM('StatOff'))
205  
206 if (Informant_Khaos_Registered) then
207 Khaos.setSetKeyParameter("Informant", "enabled", "checked", false)
208 end
209 end
210 end
211  
212 return state
213 end
214  
215 function restoreDefault(param, chatprint)
216 local oldLocale = InformantConfig.filters['locale']
217 local paramLocalized
218  
219 if ( (param == nil) or (param == "") ) then
220 return
221 elseif ((param == _INFM('CmdClearAll')) or (param == "all")) then
222 param = "all";
223 InformantConfig.filters = {};
224 else
225 paramLocalized = param
226 param = delocalizeCommand(param)
227 Informant.SetFilter(param, nil);
228 end
229  
230 -- Apply defaults for settings that went missing
231 Informant.SetFilterDefaults();
232  
233 -- Apply new locale if needed
234 if (oldLocale ~= InformantConfig.filters['locale']) then setLocale(InformantConfig.filters['locale']); end
235  
236 if (chatprint) then
237 if (param == "all") then
238 chatPrint(_INFM('FrmtActDefaultall'));
239 for k,v in pairs(InformantConfig.filters) do
240 setKhaosSetKeyValue(k, Informant.GetFilterVal(k));
241 end
242 else
243 chatPrint(string.format(_INFM('FrmtActDefault'), paramLocalized));
244 setKhaosSetKeyValue(param, Informant.GetFilterVal(param));
245 end
246 end
247 end
248  
249 function genVarSet(variable, param, chatprint)
250 if (type(param) == "string") then
251 param = delocalizeFilterVal(param);
252 end
253  
254 if (param == "on" or param == "off" or type(param) == "boolean") then
255 Informant.SetFilter(variable, param);
256 elseif (param == "toggle" or param == nil or param == "") then
257 param = Informant.SetFilter(variable, not Informant.GetFilter(variable));
258 end
259  
260 if (chatprint) then
261 if (Informant.GetFilter(variable)) then
262 chatPrint(string.format(_INFM('FrmtActEnable'), localizeCommand(variable)))
263 setKhaosSetKeyValue(variable, true)
264 else
265 chatPrint(string.format(_INFM('FrmtActDisable'), localizeCommand(variable)))
266 setKhaosSetKeyValue(variable, false)
267 end
268 end
269 end
270  
271 local function getKhaosLocaleList()
272 local options = { [_INFM('CmdDefault')] = 'default' };
273 for locale, data in InformantLocalizations do
274 options[locale] = locale;
275 end
276 return options
277 end
278  
279 function registerKhaos()
280 local optionSet = {
281 id="Informant";
282 text="Informant";
283 helptext=function()
284 return _INFM('GuiMainHelp')
285 end;
286 difficulty=1;
287 default={checked=true};
288 options={
289 {
290 id="Header";
291 text="Informant";
292 helptext=function()
293 return _INFM('GuiMainHelp')
294 end;
295 type=K_HEADER;
296 difficulty=1;
297 };
298 {
299 id="enabled";
300 type=K_TEXT;
301 text=function()
302 return _INFM('GuiMainEnable')
303 end;
304 helptext=function()
305 return _INFM('HelpOnoff')
306 end;
307 callback=function(state)
308 onOff(state.checked)
309 end;
310 feedback=function(state)
311 if (state.checked) then
312 return _INFM('StatOn')
313 else
314 return _INFM('StatOff')
315 end
316 end;
317 check=true;
318 default={checked=true};
319 disabled={checked=false};
320 difficulty=1;
321 };
322 {
323 id="locale";
324 type=K_PULLDOWN;
325 setup = {
326 options = getKhaosLocaleList;
327 multiSelect = false;
328 };
329 text=function()
330 return _INFM('GuiLocale')
331 end;
332 helptext=function()
333 return _INFM('HelpLocale')
334 end;
335 callback = function(state)
336 end;
337 feedback = function (state)
338 setLocale(state.value);
339 return string.format(_INFM('FrmtActSet'), _INFM('CmdLocale'), state.value);
340 end;
341 default = {
342 value = getLocale();
343 };
344 disabled = {
345 value = getLocale();
346 };
347 dependencies={enabled={checked=true;}};
348 difficulty=2;
349 };
350 {
351 id="InformantInfoHeader";
352 type=K_HEADER;
353 text=function()
354 return _INFM('GuiInfoHeader')
355 end;
356 helptext=function()
357 return _INFM('GuiInfoHelp')
358 end;
359 difficulty=1;
360 };
361 {
362 id="show-icon";
363 type=K_TEXT;
364 text=function()
365 return _INFM('GuiInfoIcon')
366 end;
367 helptext=function()
368 return _INFM('HelpIcon')
369 end;
370 callback=function(state)
371 genVarSet("show-icon", state.checked)
372 end;
373 feedback=function(state)
374 if (state.checked) then
375 return (string.format(_INFM('FrmtActEnable'), _INFM('ShowIcon')))
376 else
377 return (string.format(_INFM('FrmtActDisable'), _INFM('ShowIcon')))
378 end
379 end;
380 check=true;
381 default={checked=true};
382 disabled={checked=false};
383 dependencies={enabled={checked=true}};
384 difficulty=1;
385 };
386 {
387 id="show-stack";
388 type=K_TEXT;
389 text=function()
390 return _INFM('GuiInfoStack')
391 end;
392 helptext=function()
393 return _INFM('HelpStack')
394 end;
395 callback=function(state)
396 genVarSet("show-stack", state.checked)
397 end;
398 feedback=function(state)
399 if (state.checked) then
400 return (string.format(_INFM('FrmtActEnable'), _INFM('ShowStack')))
401 else
402 return (string.format(_INFM('FrmtActDisable'), _INFM('ShowStack')))
403 end
404 end;
405 check=true;
406 default={checked=true};
407 disabled={checked=false};
408 dependencies={enabled={checked=true}};
409 difficulty=1;
410 };
411 {
412 id="show-usage";
413 type=K_TEXT;
414 text=function()
415 return _INFM('GuiInfoUsage')
416 end;
417 helptext=function()
418 return _INFM('HelpUsage')
419 end;
420 callback=function(state)
421 genVarSet("show-usage", state.checked)
422 end;
423 feedback=function(state)
424 if (state.checked) then
425 return (string.format(_INFM('FrmtActEnable'), _INFM('ShowUsage')))
426 else
427 return (string.format(_INFM('FrmtActDisable'), _INFM('ShowUsage')))
428 end
429 end;
430 check=true;
431 default={checked=true};
432 disabled={checked=false};
433 dependencies={enabled={checked=true}};
434 difficulty=1;
435 };
436 {
437 id="show-quest";
438 type=K_TEXT;
439 text=function()
440 return _INFM('GuiInfoQuest')
441 end;
442 helptext=function()
443 return _INFM('HelpQuest')
444 end;
445 callback=function(state)
446 genVarSet("show-quest", state.checked)
447 end;
448 feedback=function(state)
449 if (state.checked) then
450 return (string.format(_INFM('FrmtActEnable'), _INFM('ShowQuest')))
451 else
452 return (string.format(_INFM('FrmtActDisable'), _INFM('ShowQuest')))
453 end
454 end;
455 check=true;
456 default={checked=true};
457 disabled={checked=false};
458 dependencies={enabled={checked=true}};
459 difficulty=1;
460 };
461 {
462 id="show-merchant";
463 type=K_TEXT;
464 text=function()
465 return _INFM('GuiInfoMerchant')
466 end;
467 helptext=function()
468 return _INFM('HelpMerchant')
469 end;
470 callback=function(state)
471 genVarSet("show-merchant", state.checked)
472 end;
473 feedback=function(state)
474 if (state.checked) then
475 return (string.format(_INFM('FrmtActEnable'), _INFM('ShowMerchant')))
476 else
477 return (string.format(_INFM('FrmtActDisable'), _INFM('ShowMerchant')))
478 end
479 end;
480 check=true;
481 default={checked=true};
482 disabled={checked=false};
483 dependencies={enabled={checked=true}};
484 difficulty=1;
485 };
486 {
487 id="InformantVendorHeader";
488 type=K_HEADER;
489 text=function()
490 return _INFM('GuiVendorHeader')
491 end;
492 helptext=function()
493 return _INFM('GuiVendorHelp')
494 end;
495 difficulty=1;
496 };
497 {
498 id="show-vendor";
499 type=K_TEXT;
500 text=function()
501 return _INFM('GuiVendor')
502 end;
503 helptext=function()
504 return _INFM('HelpVendor')
505 end;
506 callback=function(state)
507 genVarSet("show-vendor", state.checked)
508 end;
509 feedback=function(state)
510 if (state.checked) then
511 return (string.format(_INFM('FrmtActEnable'), _INFM('ShowVendor')))
512 else
513 return (string.format(_INFM('FrmtActDisable'), _INFM('ShowVendor')))
514 end
515 end;
516 check=true;
517 default={checked=true};
518 disabled={checked=false};
519 dependencies={enabled={checked=true}};
520 difficulty=1;
521 };
522 {
523 id="show-vendor-buy";
524 type=K_TEXT;
525 text=function()
526 return _INFM('GuiVendorBuy')
527 end;
528 helptext=function()
529 return _INFM('HelpVendorBuy')
530 end;
531 callback=function(state)
532 genVarSet("show-vendor-buy", state.checked)
533 end;
534 feedback=function(state)
535 if (state.checked) then
536 return (string.format(_INFM('FrmtActEnable'), _INFM('ShowVendorBuy')))
537 else
538 return (string.format(_INFM('FrmtActDisable'), _INFM('ShowVendorBuy')))
539 end
540 end;
541 check=true;
542 default={checked=true};
543 disabled={checked=false};
544 dependencies={["show-vendor"]={checked=true}; enabled={checked=true}};
545 difficulty=2;
546 };
547 {
548 id="show-vendor-sell";
549 type=K_TEXT;
550 text=function()
551 return _INFM('GuiVendorSell')
552 end;
553 helptext=function()
554 return _INFM('HelpVendorSell')
555 end;
556 callback=function(state)
557 genVarSet("show-vendor-sell", state.checked)
558 end;
559 feedback=function(state)
560 if (state.checked) then
561 return (string.format(_INFM('FrmtActEnable'), _INFM('ShowVendorSell')))
562 else
563 return (string.format(_INFM('FrmtActDisable'), _INFM('ShowVendorSell')))
564 end
565 end;
566 check=true;
567 default={checked=true};
568 disabled={checked=false};
569 dependencies={["show-vendor"]={checked=true}; enabled={checked=true}};
570 difficulty=2;
571 };
572  
573 {
574 id="InformantEmbedHeader";
575 type=K_HEADER;
576 text=function()
577 return _INFM('GuiEmbedHeader')
578 end;
579 helptext=function()
580 return _INFM('HelpEmbed')
581 end;
582 difficulty=1;
583 };
584 {
585 id="embed";
586 type=K_TEXT;
587 text=function()
588 return _INFM('GuiEmbed')
589 end;
590 helptext=function()
591 return _INFM('HelpEmbed')
592 end;
593 callback=function(state)
594 genVarSet("embed", state.checked)
595 end;
596 feedback=function(state)
597 if (state.checked) then
598 return (string.format(_INFM('FrmtActEnable'), _INFM('CmdEmbed')))
599 else
600 return (string.format(_INFM('FrmtActDisable'), _INFM('CmdEmbed')))
601 end
602 end;
603 check=true;
604 default={checked=false};
605 disabled={checked=false};
606 dependencies={enabled={checked=true}};
607 difficulty=1;
608 };
609 {
610 id="InformantOtherHeader";
611 type=K_HEADER;
612 text=function()
613 return _INFM('GuiOtherHeader')
614 end;
615 helptext=function()
616 return _INFM('GuiOtherHelp')
617 end;
618 difficulty=1;
619 };
620 {
621 id="DefaultAll";
622 type=K_BUTTON;
623 setup={
624 buttonText = function()
625 return _INFM('GuiDefaultAllButton')
626 end;
627 };
628 text=function()
629 return _INFM('GuiDefaultAll')
630 end;
631 helptext=function()
632 return _INFM('GuiDefaultAllHelp')
633 end;
634 callback=function()
635 restoreDefault(_INFM('CmdClearAll'))
636 end;
637 feedback=function()
638 return _INFM('FrmtActDefaultall');
639 end;
640 dependencies={enabled={checked=true}};
641 difficulty=1;
642 };
643 {
644 id="DefaultOption";
645 type=K_EDITBOX;
646 setup = {
647 callOn = {"tab", "escape", "enter"};
648 };
649 text=function()
650 return _INFM('GuiDefaultOption')
651 end;
652 helptext=function()
653 return _INFM('HelpDefault')
654 end;
655 callback = function(state)
656 restoreDefault(state.value)
657 end;
658 feedback = function (state)
659 if (state.value == _INFM('CmdClearAll')) then
660 return _INFM('FrmtActDefaultall')
661 else
662 return string.format(_INFM('FrmtActDefault'), state.value)
663 end
664 end;
665 default = {
666 value = ""
667 };
668 disabled = {
669 value = ""
670 };
671 dependencies={enabled={checked=true}};
672 difficulty=4;
673 };
674 };
675 };
676  
677 Khaos.registerOptionSet("tooltip",optionSet)
678 Informant_Khaos_Registered = true
679 Khaos.refresh();
680  
681 return true
682 end
683  
684 function isValidLocale(param)
685 return (InformantLocalizations and InformantLocalizations[param])
686 end
687  
688 function setLocale(param, chatprint)
689 param = delocalizeFilterVal(param);
690 local validLocale = nil;
691  
692 if (param == 'default') or (param == 'off') then
693 Babylonian.SetOrder('');
694 validLocale = true;
695  
696 elseif (isValidLocale(param)) then
697 Babylonian.SetOrder(param);
698 validLocale = true;
699  
700 else
701 validLocale = false;
702 end
703  
704 BINDING_HEADER_INFORMANT_HEADER = "Informant";
705 BINDING_NAME_INFORMANT_POPUPDOWN = _INFM('MesgToggleWindow');
706  
707 if (chatprint) then
708 if (validLocale) then
709 chatPrint(string.format(_INFM('FrmtActSet'), _INFM('CmdLocale'), param));
710 setKhaosSetKeyValue('locale', param);
711  
712 else
713 chatPrint(string.format(_INFM("FrmtUnknownLocale"), param));
714 local locales = " ";
715 for locale, data in pairs(InformantLocalizations) do
716 locales = locales .. " '" .. locale .. "' ";
717 end
718 chatPrint(locales);
719 end
720 end
721  
722 commandMap = nil;
723 commandMapRev = nil;
724 end
725  
726 function chatPrint(msg)
727 if (DEFAULT_CHAT_FRAME) then
728 DEFAULT_CHAT_FRAME:AddMessage(msg, 0.25, 0.55, 1.0);
729 end
730 end
731  
732 --------------------------------------
733 -- Localization functions --
734 --------------------------------------
735  
736 function delocalizeFilterVal(value)
737 if (value == _INFM('CmdOn')) then
738 return 'on';
739 elseif (value == _INFM('CmdOff')) then
740 return 'off';
741 elseif (value == _INFM('CmdDefault')) then
742 return 'default';
743 elseif (value == _INFM('CmdToggle')) then
744 return 'toggle';
745 else
746 return value;
747 end
748 end
749  
750 function localizeFilterVal(value)
751 local result
752 if (value == 'on') then
753 result = _INFM('CmdOn');
754 elseif (value == 'off') then
755 result = _INFM('CmdOff');
756 elseif (value == 'default') then
757 result = _INFM('CmdDefault');
758 elseif (value == 'toggle') then
759 result = _INFM('CmdToggle');
760 end
761 if (result) then return result; else return value; end
762 end
763  
764 function getLocalizedFilterVal(key)
765 return localizeFilterVal(Informant.GetFilterVal(key))
766 end
767  
768 -- Turns a localized slash command into the generic English version of the command
769 function delocalizeCommand(cmd)
770 if (not commandMap) then buildCommandMap(); end
771 local result = commandMap[cmd];
772 if (result) then return result; else return cmd; end
773 end
774  
775 -- Translate a generic English slash command to the localized version, if available
776 function localizeCommand(cmd)
777 if (not commandMapRev) then buildCommandMap(); end
778 local result = commandMapRev[cmd];
779 if (result) then return result; else return cmd; end
780 end
781  
782 -- Globally accessible functions
783 Informant.SetLocale = setLocale;