vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Localization
3 Embeddable addon for selecting a global localization for addons.
4  
5 By: AnduinLothar
6  
7 Based on inspiration from Babylonian code by norganna and MentalPower.
8 Brought to you without any real xml thanks to Iriel's VirtualFrames.
9  
10 To use as an embeddable addon:
11 - Put the Localization folder inside your Interface/AddOns/<YourAddonName>/ folder.
12 - Add Localization\Localization.xml to your toc or load it in your xml before your localization files.
13 - Add Localization to the OptionalDeps in your toc
14  
15 To use as an addon library:
16 - Put the Localization folder inside your Interface/AddOns/ folder.
17 - Add Localization to the Dependencies in your toc
18  
19 Note: The AddonName passed to most functions must be identical to the AddonName as returned by arg1 of ADDON_LOADED for Load on Demand addons.
20  
21 $Id: Localization.lua 3547 2006-05-16 02:35:13Z karlkfi $
22 $Rev: 3547 $
23 $LastChangedBy: karlkfi $
24 $Date: 2006-05-15 19:35:13 -0700 (Mon, 15 May 2006) $
25 ]]--
26  
27 local LOCALIZATION_NAME = "Localization"
28 local LOCALIZATION_VERSION = 0.06
29 local LOCALIZATION_LAST_UPDATED = "May 4, 2006"
30 local LOCALIZATION_AUTHOR = "AnduinLothar"
31 local LOCALIZATION_EMAIL = "karlkfi@cosmosui.org"
32 local LOCALIZATION_WEBSITE = "http://www.wowwiki.com/Localization_Lib"
33  
34 ------------------------------------------------------------------------------
35 --[[ Embedded Sub-Library Load Algorithm ]]--
36 ------------------------------------------------------------------------------
37  
38 if (not Localization) then
39 Localization = {}
40 RegisterCVar("PreferedLocale", "")
41 RegisterCVar("RemoveUnusedLocales", 'false')
42 end
43 local isBetterInstanceLoaded = ( Localization.version and Localization.version >= LOCALIZATION_VERSION )
44  
45 if (not isBetterInstanceLoaded) then
46  
47 ------------------------------------------------------------------------------
48 --[[ Variables ]]--
49 ------------------------------------------------------------------------------
50  
51 Localization.version = LOCALIZATION_VERSION
52 Localization.clientLocale = GetLocale()
53 if (not Localization.preferedLocale) then
54 local pref = GetCVar("PreferedLocale")
55 if (pref and pref ~= "") then
56 Localization.preferedLocale = pref
57 else
58 Localization.preferedLocale = Localization.clientLocale
59 --Localization.promptForPrefrence = true
60 end
61 end
62 if (not Localization.callbacks) then
63 Localization.callbacks = {}
64 end
65 if (not Localization.localizedStrings) then
66 Localization.localizedStrings = {}
67 end
68 if (not Localization.localizedGlobalStrings) then
69 Localization.localizedGlobalStrings = {}
70 end
71 if (not Localization.protected) then
72 Localization.protected = {}
73 end
74  
75 ------------------------------------------------------------------------------
76 --[[ User Addon Functions ]]--
77 ------------------------------------------------------------------------------
78  
79 function Localization.RegisterAddonStrings(locale, addon, stringTable, eraseOrig, protect)
80 -- Registers strings with the global database by addon and locale
81 -- 'eraseOrig' will remove all previously registered strings for this addon in this locale
82 -- 'protect' will not allow this information to be deleted by RemoveUnusedLocales. For internal use only. Used to protect the language selection screen text.
83 -- This method is highly prefered over RegisterGlobalAddonStrings so as not to pollute the global namespace.
84 if (not locale) then
85 DEFAULT_CHAT_FRAME:AddMessage("[Localization] WARNING: locale for RegisterAddonStrings invalid.")
86 return
87 end
88 if (not addon) then
89 DEFAULT_CHAT_FRAME:AddMessage("[Localization] WARNING: addon for RegisterAddonStrings invalid.")
90 end
91 if (not Localization.localizedStrings[locale]) then
92 Localization.localizedStrings[locale] = {}
93 end
94 local lang = Localization.localizedStrings[locale]
95 if (eraseOrig or not lang[addon]) then
96 lang[addon] = stringTable
97 else
98 lang = lang[addon]
99 for key, text in stringTable do
100 lang[key] = text
101 end
102 end
103  
104 --protection
105 if (not Localization.protected[locale]) then
106 Localization.protected[locale] = {}
107 end
108 if (protect and not Localization.protected[locale][addon]) then
109 Localization.protected[locale][addon] = true;
110 end
111 end
112  
113 function Localization.RegisterGlobalAddonStrings(locale, addon, stringTable, eraseOrig, protect)
114 -- Registers strings with the global database by addon and locale
115 -- 'eraseOrig' will remove all previously registered strings for this addon in this locale
116 -- 'protect' will not allow this information to be deleted by RemoveUnusedLocales. For internal use only. Used to protect the language selection screen text.
117 -- This method may be useful if the strings are called frequently or are used in bindings.
118 if (not locale) then
119 DEFAULT_CHAT_FRAME:AddMessage("[Localization] WARNING: locale for RegisterGlobalAddonStrings invalid.")
120 return
121 end
122 if (not addon) then
123 DEFAULT_CHAT_FRAME:AddMessage("[Localization] WARNING: addon for RegisterGlobalAddonStrings invalid.")
124 end
125 if (not Localization.localizedGlobalStrings[locale]) then
126 Localization.localizedGlobalStrings[locale] = {}
127 end
128 local lang = Localization.localizedGlobalStrings[locale]
129 if (eraseOrig or not lang[addon]) then
130 lang[addon] = stringTable
131 else
132 lang = lang[addon]
133 for key, text in stringTable do
134 lang[key] = text
135 end
136 end
137  
138 --protection
139 if (not Localization.protected[locale]) then
140 Localization.protected[locale] = {}
141 end
142 if (protect and not Localization.protected[locale][addon]) then
143 Localization.protected[locale][addon] = true;
144 end
145 end
146  
147 function Localization.SetAddonDefault(addon, locale)
148 -- Sets required Addon default locale. It should have values for all availible strings.
149 if (not Localization.defaults) then
150 Localization.defaults = {}
151 end
152 Localization.defaults[addon] = locale
153 end
154  
155 function Localization.RegisterCallback(key, callback, silent)
156 -- Registers optional callback function to update your addon's strings when the prefered locale is changed
157 if (not silent) then
158 if (not key) then
159 DEFAULT_CHAT_FRAME:AddMessage("[Localization] WARNING: key for RegisterCallback invalid.")
160 return
161 end
162 if (not callback) then
163 DEFAULT_CHAT_FRAME:AddMessage("[Localization] WARNING: callback for RegisterCallback invalid.")
164 end
165 if (Localization.callbacks[key]) then
166 DEFAULT_CHAT_FRAME:AddMessage("[Localization] WARNING: callback allready exists for key: " .. key)
167 end
168 end
169 Localization.callbacks[key] = callback
170 end
171  
172 function Localization.GetString(addon, stringKey)
173 -- returns the globally prefered localization, else client locale, else addon default
174 -- It is recommended you make an addon file local refrence to shorten this call in your code:
175 -- local function TEXT(key) return Localization.GetString("YourAddonName", key) end
176 local lang;
177 if (Localization.preferedLocale) then
178 lang = Localization.localizedStrings[Localization.preferedLocale]
179 if (lang[addon] and lang[addon][stringKey]) then
180 return lang[addon][stringKey]
181 elseif (Localization.preferedLocale == "enGB") then
182 -- enGB falls back on enUS
183 lang = Localization.localizedStrings["enUS"]
184 if (lang and lang[addon] and lang[addon][stringKey]) then
185 return lang[addon][stringKey]
186 end
187 end
188 end
189 lang = Localization.localizedStrings[Localization.clientLocale]
190 if (lang[addon] and lang[addon][stringKey]) then
191 return lang[addon][stringKey]
192 elseif (Localization.clientLocale == "enGB") then
193 -- enGB falls back on enUS
194 lang = Localization.localizedStrings["enUS"]
195 if (lang and lang[addon] and lang[addon][stringKey]) then
196 return lang[addon][stringKey]
197 end
198 end
199  
200 return Localization.localizedStrings[Localization.defaults[addon]][addon][stringKey]
201 end
202  
203 function Localization.GetClientString(addon, stringKey)
204 -- returns the client localization, else addon default
205 local lang = Localization.localizedStrings[Localization.clientLocale]
206 if (lang[addon] and lang[addon][stringKey]) then
207 return lang[addon][stringKey]
208 elseif (Localization.clientLocale == "enGB") then
209 -- enGB falls back on enUS
210 lang = Localization.localizedStrings["enUS"]
211 if (lang and lang[addon] and lang[addon][stringKey]) then
212 return lang[addon][stringKey]
213 end
214 end
215  
216 return Localization.localizedStrings[Localization.defaults[addon]][addon][stringKey]
217 end
218  
219 function Localization.GetSpecificString(language, addon, stringKey)
220 if (Localization.localizedStrings[language] and Localization.localizedStrings[language][addon]) then
221 return Localization.localizedStrings[language][addon][stringKey]
222 end
223 end
224  
225 function Localization.AssignAddonGlobalStrings(addon)
226 -- Assigns global values to the keys of the global String database
227 -- First choice is prefered localization, else client locale, else addon default
228 -- This function must be called in your addon after SetAddonDefault and before the global strings can be used.
229 local prefLang = Localization.preferedLocale and Localization.localizedGlobalStrings[Localization.preferedLocale] and Localization.localizedGlobalStrings[Localization.preferedLocale][addon]
230 local clientLang = Localization.clientLocale and Localization.localizedGlobalStrings[Localization.clientLocale] and Localization.localizedGlobalStrings[Localization.clientLocale][addon]
231 local preferedIsGB = (Localization.preferedLocale == "enGB")
232 local enUSLang = Localization.localizedGlobalStrings["enUS"] and Localization.localizedGlobalStrings["enUS"][addon]
233 local defaultLang = Localization.localizedGlobalStrings[Localization.defaults[addon]][addon]
234  
235 for key, text in defaultLang do
236 if (prefLang and prefLang[key]) then
237 setglobal(key, prefLang[key])
238 elseif (preferedIsGB and enUSLang and enUSLang[key]) then
239 setglobal(key, enUSLang[key])
240 elseif (clientLang and clientLang[key]) then
241 setglobal(key, clientLang[key])
242 else
243 setglobal(key, text)
244 end
245 end
246  
247 end
248  
249 ------------------------------------------------------------------------------
250 --[[ Internal Functions ]]--
251 ------------------------------------------------------------------------------
252  
253 local function TEXT(key) return Localization.GetString("Localization", key) end
254  
255 function Localization.SetGlobalPreference(localization)
256 if (type(localization) ~= "string") then
257 return
258 end
259 -- Global preference will be used for GetString
260 Localization.preferedLocale = localization
261 SetCVar("PreferedLocale", localization)
262 for key, func in Localization.callbacks do
263 func(localization)
264 end
265 end
266  
267 function Localization.GetGlobalPreference()
268 return GetCVar("PreferedLocale")
269 end
270  
271 function Localization.RemoveUnusedLocales()
272 -- Keeps current prefered and client Localizations as well as addon defaults, removes all else from memory
273 -- reloadui to get back deleted localized strings
274 for locale, addonTable in Localization.localizedStrings do
275 if (locale ~= Localization.clientLocale and locale ~= Localization.preferedLocale) then
276 local used;
277 for addon, default in Localization.defaults do
278 if (locale == default or Localization.protected[locale][addon]) then
279 used = true
280 else
281 Localization.localizedStrings[locale][addon] = nil
282 end
283 end
284 if (not used) then
285 Localization.localizedStrings[locale] = nil
286 end
287 end
288 end
289 end
290  
291 function Localization.AssignAllGlobalStrings()
292 -- Assigns global values to the keys of the global String database
293 -- First choice is prefered localization, else client locale, else addon default
294 -- This function is called when the Global preference is updated
295 local prefLang = Localization.preferedLocale and Localization.localizedGlobalStrings[Localization.preferedLocale]
296 local clientLang = Localization.clientLocale and Localization.localizedGlobalStrings[Localization.clientLocale]
297 local preferedIsGB = (Localization.preferedLocale == "enGB")
298 local enUSLang = Localization.localizedGlobalStrings["enUS"]
299  
300 for addon, locale in Localization.defaults do
301 local lang = Localization.localizedGlobalStrings[locale]
302 if (lang and lang[addon]) then
303 -- If there aren't any default global strings for this local or addon, don't bother trying to assign any from other locales
304 for key, text in lang[addon] do
305 if (prefLang and prefLang[addon] and prefLang[addon][key]) then
306 setglobal(key, prefLang[addon][key])
307 elseif (preferedIsGB and enUSLang and enUSLang[addon] and enUSLang[addon][key]) then
308 setglobal(key, enUSLang[addon][key])
309 elseif (clientLang and clientLang[addon] and clientLang[addon][key]) then
310 setglobal(key, clientLang[addon][key])
311 else
312 setglobal(key, text)
313 end
314 end
315 end
316 end
317  
318 end
319  
320 ------------------------------------------------------------------------------
321 --[[ Frame Scripts ]]--
322 ------------------------------------------------------------------------------
323  
324 function Localization.Prompt()
325 --Show Frame with dropdown asking for prefered language
326 LanguageSelectionFrame:Show()
327 --Have option checkbox for removing unused languages
328 --Select options and then click Confirm/Cancil
329  
330 --will Khaos need an update?
331 end
332  
333 function Localization.UpdatePrompt()
334 LanguageSelectionFrameConfigurationSelectText:SetText(TEXT(Localization.preferedLocale));
335 LanguageSelectionFrameText:SetText(TEXT("SelectPreferred"))
336 LanguageSelectionFrameCheckBoxText:SetText(TEXT("RemoveUnused"))
337 LanguageSelectionFrameLeftButton:SetText(TEXT("Confirm"))
338 LanguageSelectionFrameRightButton:SetText(TEXT("Cancel"))
339 end
340  
341 function Localization.OnEvent()
342 if (event == "VARIABLES_LOADED" or (Localization.variablesHaveLoaded and event == "ADDON_LOADED")) then
343 Localization.variablesHaveLoaded = true
344 if (not LanguageSelectionFrame:IsShown()) then
345 if (Localization.promptForPrefrence) then
346 Localization.Prompt()
347 else
348 Localization.SetGlobalPreference(Localization.preferedLocale)
349 if (GetCVar("RemoveUnusedLocales") == 'true') then
350 Localization.RemoveUnusedLocales()
351 end
352 --[[
353 if (arg1) then
354 -- ADDON_LOADED passed Addon Name as arg1
355 if (Localization.defaults[arg1]) then
356 Localization.AssignAllGlobalStrings(arg1)
357 end
358 else
359 Localization.AssignAllGlobalStrings()
360 end
361 ]]--
362 end
363 end
364 end
365 if (not Localization.earthButtonLoaded) then
366 Localization.earthButtonLoaded = true
367 if(EarthFeature_AddButton) then
368 EarthFeature_AddButton(
369 {
370 id = LOCALIZATION_NAME;
371 name = function() return TEXT("Localization") end;
372 subtext = function() return TEXT("ShowPrompt") end;
373 tooltip = function() return TEXT("EarthTooltip") end;
374 icon = "Interface\\Icons\\INV_Misc_Book_06";
375 callback = Localization.Prompt;
376 }
377 );
378 end
379 if(CT_RegisterMod) then
380 -- This will only work for whatever language is prefered when it's run.
381 -- It would require substantial hacking to force it to update when the locale changes.
382 CT_RegisterMod(
383 LOCALIZATION_NAME,
384 TEXT("ShowPrompt"),
385 5,
386 "Interface\\Icons\\INV_Misc_Book_06",
387 TEXT("EarthTooltip"),
388 "on",
389 "",
390 Localization.Prompt
391 );
392 end
393 if(myAddOnsFrame_Register) then
394 myAddOnsFrame_Register(
395 {
396 name = LOCALIZATION_NAME;
397 version = Localization.version;
398 releaseDate = LOCALIZATION_LAST_UPDATED;
399 author = LOCALIZATION_AUTHOR;
400 email = LOCALIZATION_EMAIL;
401 website = LOCALIZATION_WEBSITE;
402 category = MYADDONS_CATEGORY_OTHERS;
403 optionsframe = "LanguageSelectionFrame";
404 }
405 );
406 end
407 end
408 end
409  
410 function Localization.SellectionFrame_OnShow()
411 if (not Localization.preferedLocale) then
412 Localization.SetGlobalPreference(Localization.clientLocale)
413 else
414 Localization.UpdatePrompt()
415 end
416 LanguageSelectionFrame.oldLocalePref = Localization.preferedLocale
417 LanguageSelectionFrameCheckBox:SetChecked( GetCVar("RemoveUnusedLocales") == 'true' )
418 end
419  
420 function Localization.ConfirmPreference()
421 if (LanguageSelectionFrameCheckBox:GetChecked()) then
422 SetCVar("RemoveUnusedLocales", 'true')
423 Localization.RemoveUnusedLocales()
424 else
425 SetCVar("RemoveUnusedLocales", 'false')
426 end
427 this:GetParent():Hide()
428 end
429  
430 function Localization.CancelPreference()
431 Localization.SetGlobalPreference(LanguageSelectionFrame.oldLocalePref)
432 this:GetParent():Hide()
433 end
434  
435 ------------------------------------------------------------------------------
436 --[[ Menu Functions ]]--
437 ------------------------------------------------------------------------------
438  
439 function Localization.LoadDropDownMenu()
440  
441 -- Title
442 local info = {}
443 info.text = TEXT("AvailLangs")
444 info.notClickable = 1
445 info.isTitle = 1
446 UIDropDownMenu_AddButton(info, 1)
447  
448 -- Client Locale at top
449 local info = {}
450 info.value = Localization.clientLocale
451 info.text = TEXT(info.value)
452 if (Localization.preferedLocale == info.value) then
453 info.checked = true
454 end
455 info.func = function()
456 Localization.SetGlobalPreference(info.value)
457 end
458 UIDropDownMenu_AddButton(info, 1)
459  
460 -- Note that the current menu frame will only allow for 32 objects, 31 locales + title
461 for locale, AddonList in Localization.localizedStrings do
462 if (locale ~= Localization.clientLocale) then
463 local info = {}
464 info.value = locale
465 info.text = TEXT(info.value)
466 if (not Localization.GetSpecificString(info.value, "Localization", info.value)) then
467 -- If that local isn't localized inot a language name, use the locale string
468 info.text = info.value
469 end
470 if (Localization.preferedLocale == info.value) then
471 info.checked = true
472 end
473 info.func = function()
474 Localization.SetGlobalPreference(info.value)
475 end
476 UIDropDownMenu_AddButton(info, 1)
477 end
478 end
479  
480 -- Set the width of the menu to the size of the dropdown bar
481 Localization.SetDropDownWidth(1, 200)
482  
483 -- nil the displayMode so that the rest of ToggleDropDownMenu doesn't error on the fake frame
484 LanguageDropDown.displayMode = nil
485 end
486  
487 function Localization.SetDropDownWidth(id, width)
488 local dropdown = getglobal("DropDownList"..id)
489 dropdown:SetWidth(width)
490 local i = 1
491 local button = getglobal("DropDownList"..id.."Button"..i)
492 while (button) do
493 -- Left is aligned by default, align the right side too.
494 button:SetPoint("RIGHT", dropdown, "RIGHT", -10,0)
495 i = i + 1
496 button = getglobal("DropDownList"..id.."Button"..i)
497 end
498 dropdown.noResize = 1
499 end
500  
501 function Localization.ShowDropDown()
502 LanguageDropDown.displayMode = "MENU"
503 ToggleDropDownMenu(1, nil, LanguageDropDown, this:GetName(), 0, 0, "TOPLEFT")
504 PlaySound("igMainMenuOptionCheckBoxOn")
505 end
506  
507 ------------------------------------------------------------------------------
508 --[[ Frame Templates - Requires Iriel's VirtualFrames package ]]--
509 ------------------------------------------------------------------------------
510  
511 local VF = IrielVirtualFrames:GetInstance("KarlPrototype-2-dev")
512  
513 VF:Register("EarthCheckButtonTemplate", {
514 type = "CheckButton";
515 name = "EarthCheckButtonTemplate";
516 Size = { 32, 32, };
517 NormalTexture = {
518 type = "Texture";
519 name = "$parentNormalTexture";
520 Texture = "Interface\\Buttons\\UI-CheckBox-Up";
521 };
522 PushedTexture = {
523 type = "Texture";
524 name = "$parentPushedTexture";
525 Texture = "Interface\\Buttons\\UI-CheckBox-Down";
526 };
527 HighlightTexture = {
528 type = "Texture";
529 name = "$parentHighlightTexture";
530 Texture = "Interface\\Buttons\\UI-CheckBox-Highlight";
531 AlphaMode = "ADD";
532 };
533 CheckedTexture = {
534 type = "Texture";
535 name = "$parentCheckedTexture";
536 Texture = "Interface\\Buttons\\UI-CheckBox-Check";
537 };
538 DisabledCheckedTexture = {
539 type = "Texture";
540 name = "$parentDisabledCheckedTexture";
541 Texture = "Interface\\Buttons\\UI-CheckBox-Check-Disabled";
542 };
543 -- Regions
544 {
545 type = "FontString";
546 name = "$parentText";
547 inherits = "GameFontNormalSmall";
548 DrawLayer = "ARTWORK";
549 Anchors = {
550 {"LEFT", nil, "RIGHT", -2, 0, };
551 };
552 };
553 });
554  
555 VF:Register("EarthPanelButtonUpTexture", {
556 type = "Texture";
557 name = "EarthPanelButtonUpTexture";
558 Texture = "Interface\\Buttons\\UI-Panel-Button-Up";
559 TexCoords = { left = 0, right = 0.625, top = 0, bottom = 0.6875, };
560 });
561  
562 VF:Register("EarthPanelButtonDownTexture", {
563 type = "Texture";
564 name = "EarthPanelButtonDownTexture";
565 Texture = "Interface\\Buttons\\UI-Panel-Button-Down";
566 TexCoords = { left = 0, right = 0.625, top = 0, bottom = 0.6875, };
567 });
568  
569 VF:Register("EarthPanelButtonDisabledTexture", {
570 type = "Texture";
571 name = "EarthPanelButtonDisabledTexture";
572 Texture = "Interface\\Buttons\\UI-Panel-Button-Disabled";
573 TexCoords = { left = 0, right = 0.625, top = 0, bottom = 0.6875, };
574 });
575  
576 VF:Register("EarthPanelButtonDisabledDownTexture", {
577 type = "Texture";
578 name = "EarthPanelButtonDisabledDownTexture";
579 Texture = "Interface\\Buttons\\UI-Panel-Button-Disabled-Down";
580 TexCoords = { left = 0, right = 0.625, top = 0, bottom = 0.6875, };
581 });
582  
583 VF:Register("EarthPanelButtonHighlightTexture", {
584 type = "Texture";
585 name = "EarthPanelButtonHighlightTexture";
586 Texture = "Interface\\Buttons\\UI-Panel-Button-Highlight";
587 AlphaMode = "ADD";
588 TexCoords = { left = 0, right = 0.625, top = 0, bottom = 0.6875, };
589 });
590  
591 VF:Register("EarthPanelButtonTemplate", {
592 type = "Button";
593 name = "EarthPanelButtonTemplate";
594 NormalText = {
595 type = "Font";
596 name = "$parentText";
597 inherits = "GameFontNormal";
598 };
599 DisabledText = {
600 type = "Font";
601 inherits = "GameFontDisable";
602 };
603 HighlightText = {
604 type = "Font";
605 inherits = "GameFontHighlight";
606 };
607 NormalTexture = {
608 type = "Texture";
609 inherits = "EarthPanelButtonUpTexture";
610 };
611 PushedTexture = {
612 type = "Texture";
613 inherits = "EarthPanelButtonDownTexture";
614 };
615 DisabledTexture = {
616 type = "Texture";
617 inherits = "EarthPanelButtonDisabledTexture";
618 };
619 HighlightTexture = {
620 type = "Texture";
621 inherits = "EarthPanelButtonHighlightTexture";
622 };
623 });
624  
625 VF:Register("LoginSelectionFrameTemplate", {
626 type = "Frame";
627 Hidden = true;
628 Parent = "UIParent";
629 Size = { 300, 150, };
630 Anchors = {
631 {"CENTER", "$parent", "CENTER", 0, 40, };
632 };
633 Backdrop = {
634 bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
635 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
636 tile = true, tileSize = 16, edgeSize = 16, -- misc values
637 insets = { left = 4, right = 4, top = 4, bottom = 4, },
638 };
639 -- Regions
640 {
641 type = "FontString";
642 name = "$parentText";
643 inherits = "GameFontNormal";
644 --DrawLayer = "LOW";
645 --MaxLines = 12;
646 Size = { 0, 10, };
647 Anchors = {
648 {"TOP", "$parent", "TOP", 0, -20, };
649 };
650 };
651 -- Children
652 {
653 type = "Frame";
654 name = "$parentConfigurationSelect";
655 Size = { 220, 32, };
656 Anchors = {
657 {"CENTER", "$parent", "CENTER", 0, 10, };
658 };
659 -- Regions
660 {
661 type = "Texture";
662 name = "$parentLeft";
663 DrawLayer = "ARTWORK";
664 Texture = "Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame";
665 Size = { 25, 64, };
666 Anchors = {
667 {"TOPLEFT", nil, "TOPLEFT", 0, 17, };
668 };
669 TexCoords = { left = 0, right = 0.1953125, top = 0, bottom = 1, };
670 };
671 {
672 type = "Texture";
673 name = "$parentMiddle";
674 DrawLayer = "ARTWORK";
675 Texture = "Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame";
676 Size = { 180, 64, };
677 Anchors = {
678 {"LEFT", "$parentLeft", "RIGHT"};
679 };
680 TexCoords = { left = 0.1953125, right = 0.8046875, top = 0, bottom = 1, };
681 };
682 {
683 type = "Texture";
684 name = "$parentRight";
685 DrawLayer = "ARTWORK";
686 Texture = "Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame";
687 Size = { 25, 64, };
688 Anchors = {
689 {"LEFT", "$parentMiddle", "RIGHT"};
690 };
691 TexCoords = { left = 0.8046875, right = 1, top = 0, bottom = 1, };
692 };
693 {
694 type = "FontString";
695 name = "$parentText";
696 inherits = "GameFontHighlightSmall";
697 DrawLayer = "ARTWORK";
698 JustifyH = "RIGHT";
699 Size = { 0, 10, };
700 Anchors = {
701 {"RIGHT", "$parentRight", "RIGHT", -43, 2, };
702 };
703 };
704 -- Children
705 {
706 type = "Button";
707 name = "$parentButton";
708 Size = { 24, 24, };
709 Anchors = {
710 {"TOPLEFT", "$parentLeft", "TOPLEFT", 16, -19, };
711 };
712 NormalTexture = {
713 type = "Texture";
714 name = "$parentNormalTexture";
715 Texture = "Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up";
716 Size = { 24, 24, };
717 Anchors = {
718 {"RIGHT", nil, "RIGHT"};
719 };
720 };
721 PushedTexture = {
722 type = "Texture";
723 name = "$parentPushedTexture";
724 Texture = "Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down";
725 Size = { 24, 24, };
726 Anchors = {
727 {"RIGHT", nil, "RIGHT"};
728 };
729 };
730 DisabledTexture = {
731 type = "Texture";
732 name = "$parentDisabledTexture";
733 Texture = "Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled";
734 Size = { 24, 24, };
735 Anchors = {
736 {"RIGHT", nil, "RIGHT"};
737 };
738 };
739 HighlightTexture = {
740 type = "Texture";
741 name = "$parentHighlightTexture";
742 Texture = "Interface\\Buttons\\UI-Common-MouseHilight";
743 AlphaMode = "ADD";
744 Size = { 24, 24, };
745 Anchors = {
746 {"RIGHT", nil, "RIGHT"};
747 };
748 };
749 };
750 };
751 {
752 type = "CheckButton";
753 name = "$parentCheckBox";
754 inherits = "EarthCheckButtonTemplate";
755 Size = { 32, 32, };
756 Anchors = {
757 {"TOPLEFT", "$parent", "LEFT", 16, -8, };
758 };
759 };
760 {
761 type = "Button";
762 name = "$parentLeftButton";
763 inherits = "EarthPanelButtonTemplate";
764 Size = { 96, 24, };
765 Anchors = {
766 {"TOP", "$parent", "CENTER", -64, -38, };
767 };
768 };
769 {
770 type = "Button";
771 name = "$parentRightButton";
772 inherits = "EarthPanelButtonTemplate";
773 Size = { 96, 24, };
774 Anchors = {
775 {"TOP", "$parent", "CENTER", 64, -38, };
776 };
777 };
778 });
779  
780 ------------------------------------------------------------------------------
781 --[[ Frame Instantiations ]]--
782 ------------------------------------------------------------------------------
783  
784 VF:Instantiate("LoginSelectionFrameTemplate", "LanguageSelectionFrame", "UIParent")
785  
786 -- Fake menu frame.... who says you need a frame, bah!
787 LanguageDropDown = {
788 initialize = Localization.LoadDropDownMenu;
789 GetName = function() return "LanguageDropDown" end;
790 SetHeight = function() end;
791 }
792  
793 ------------------------------------------------------------------------------
794 --[[ Frame Script Assignment ]]--
795 ------------------------------------------------------------------------------
796  
797 LanguageSelectionFrame:RegisterEvent("VARIABLES_LOADED")
798 LanguageSelectionFrame:RegisterEvent("ADDON_LOADED")
799  
800 LanguageSelectionFrame:SetScript("OnEvent", Localization.OnEvent)
801 LanguageSelectionFrame:SetScript("OnShow", Localization.SellectionFrame_OnShow)
802 LanguageSelectionFrameConfigurationSelectButton:SetScript("OnClick", Localization.ShowDropDown)
803 LanguageSelectionFrameLeftButton:SetScript("OnClick", Localization.ConfirmPreference)
804 LanguageSelectionFrameRightButton:SetScript("OnClick", Localization.CancelPreference)
805  
806 ------------------------------------------------------------------------------
807 --[[ Slash Command ]]--
808 ------------------------------------------------------------------------------
809  
810 SLASH_LOCALIZATION1 = "/locale"
811 SlashCmdList["LOCALIZATION"] = Localization.Prompt
812  
813 ------------------------------------------------------------------------------
814 --[[ Direct Execution ]]--
815 ------------------------------------------------------------------------------
816  
817 Localization.SetAddonDefault("Localization", "enUS")
818 Localization.RegisterCallback("AssignAllGlobalStrings", Localization.AssignAllGlobalStrings)
819 Localization.RegisterCallback("LocalizationPrompt", Localization.UpdatePrompt)
820  
821 -- Leave frame text updating until after the localization files have been loaded
822  
823 end