Quantcast

Added German and French localization. Feel free to send me localization for other clients either through PMs or in the Comments. :)

Safturento [11-11-11 - 02:24]
Added German and French localization. Feel free to send me localization for other clients either through PMs or in the Comments. :)
Filename
localization.lua
stAddonManager.lua
stAddonManager.toc
diff --git a/localization.lua b/localization.lua
new file mode 100644
index 0000000..4441c5d
--- /dev/null
+++ b/localization.lua
@@ -0,0 +1,51 @@
+local ADDON_NAME = ...
+
+local ns = select(2, ...)
+
+local L = {}
+local Locale = GetLocale()
+
+L.Search = "Search"
+L.ReloadUI = "Reload UI"
+L.Profiles = "Profiles"
+L.New_Profile = "New Profile"
+L.Enable_All = "Enable All"
+L.Disable_All = "Disable All"
+L.Profile_Name = "Profile Name"
+L.Set_To = "Set To.."
+L.Add_To = "Add To.."
+L.Remove_From = "Remove From.."
+L.Delete_Profile = "Delete Profile.."
+L.Confirm_Delete = "Are you sure you want to delete this profile? Hold down shift and click again if you are."
+
+if Locale == "deDE" then
+	L.Search = "Suchen"
+	L.ReloadUI = "Reload UI"
+	L.Profiles = "Profils"
+	L.New_Profile = "Neues Profil"
+	L.Enable_All = "Alle An"
+	L.Disable_All = "Alle Aus"
+	L.Profile_Name = "Profil Name"
+	L.Set_To = "Aktivieren.."
+	L.Add_To = "Hinzuf\195\188gen zu.."
+	L.Remove_From = "Entfernen von.."
+	L.Delete_Profile = "Profil L\195\182schen"
+	L.Confirm_Delete = "Bist du dir sicher das du dieses Profil l\195\182schen m\195\182chtest? Dann halte Shift gedr\195\188ckt und klicke nochmals."
+end
+
+if Locale == "frFR" then
+	L.Search = "Rechercher"
+	L.ReloadUI = "Recharger UI"
+	L.Profiles = "Profils"
+	L.New_Profile = "Nouveau profil"
+	L.Enable_All = "Activer tous"
+	L.Disable_All = "D\195\169sactiver tous"
+	L.Profile_Name = "profil nom"
+	L.Set_To = "Mettez \195\160.."
+	L.Add_To = "Ajouter \195\160.."
+	L.Remove_From = "Retirer de.."
+	L.Delete_Profile = "Supprimer le profil"
+	L.Confirm_Delete = "Etes-vous sr de vouloir supprimer ce profil? Maintenez la touche Shift et re-cliquez si vous tes sr."
+end
+
+ns.L = L
\ No newline at end of file
diff --git a/stAddonManager.lua b/stAddonManager.lua
index 2d5b77d..b4006d9 100644
--- a/stAddonManager.lua
+++ b/stAddonManager.lua
@@ -1,5 +1,8 @@
 local ADDON_NAME = ...

+local ns = select(2, ...)
+local L = ns.L
+
 ------------------------------------------------------
 -- MEDIA & CONFIG ------------------------------------
 ------------------------------------------------------
@@ -101,6 +104,19 @@ local function SkinScrollBar(frame, thumbTrim)
 	end
 end

+local function GetEnabledAddons()
+	local EnabledAddons = {}
+		for i=1, GetNumAddOns() do
+			local name, _, _, enabled = GetAddOnInfo(i)
+			if enabled then
+				tinsert(EnabledAddons, name)
+			end
+		end
+	return EnabledAddons
+end
+
+
+
 local function CreateMenuButton(parent, width, height, text, ...)
 	local button = CreateFrame("Button", nil, parent)
 	button:SetFrameLevel(parent:GetFrameLevel()+1)
@@ -150,34 +166,27 @@ function stAddonManager:UpdateAddonList(queryString)
 	return addons
 end

-local function GetEnabledAddons()
-	local EnabledAddons = {}
-		for i=1, GetNumAddOns() do
-			local name, _, _, enabled = GetAddOnInfo(i)
-			if enabled then
-				tinsert(EnabledAddons, name)
-			end
-		end
-	return EnabledAddons
-end
+

 function stAddonManager:LoadProfileWindow()
 	local self = stAddonManager
+	if not stAddonProfiles then stAddonProfiles = {} end
+
 	if self.ProfileWindow then ToggleFrame(self.ProfileWindow) return end
+
 	local window = CreateFrame("Frame", "stAddonManager_ProfileWindow", self)
 	window:SetPoint("TOPLEFT", self, "TOPRIGHT", 5, 0)
-	window:SetSize(150, 20)
+	window:SetSize(175, 20)
 	SkinFrame(window, true)
 	CreateBackdrop(window, true)
-

-	local hTitle = window:CreateFontString(nil, "OVERLAY")
-	hTitle:SetFont(unpack(font))
-	hTitle:SetPoint("CENTER")
-	hTitle:SetText("Profiles")
-	window.title = hTitle
+	local title = window:CreateFontString(nil, "OVERLAY")
+	title:SetFont(unpack(font))
+	title:SetPoint("CENTER")
+	title:SetText(L.Profiles)
+	window.title = title

-	local EnableAll = CreateMenuButton(window, (window:GetWidth()-15)/2, 20, "Enable All", "TOPLEFT", window, "BOTTOMLEFT", 5, -5)
+	local EnableAll = CreateMenuButton(window, (window:GetWidth()-15)/2, 20, L.Enable_All, "TOPLEFT", window, "BOTTOMLEFT", 5, -5)
 	EnableAll:SetScript("OnClick", function(self)
 		for i, addon in pairs(stAddonManager.AllAddons) do
 			EnableAddOn(addon.name)
@@ -186,7 +195,7 @@ function stAddonManager:LoadProfileWindow()
 		end
 	end)

-	local DisableAll = CreateMenuButton(window, EnableAll:GetWidth(), EnableAll:GetHeight(), "DisableAll", "TOPRIGHT", window, "BOTTOMRIGHT", -5, -5)
+	local DisableAll = CreateMenuButton(window, EnableAll:GetWidth(), EnableAll:GetHeight(), L.Disable_All, "TOPRIGHT", window, "BOTTOMRIGHT", -5, -5)
 	DisableAll:SetScript("OnClick", function(self)
 		for i, addon in pairs(stAddonManager.AllAddons) do
 			if addon.name ~= ADDON_NAME then
@@ -197,35 +206,31 @@ function stAddonManager:LoadProfileWindow()
 		end
 	end)

-	if not stAddonProfiles then
-		stAddonProfiles = {}
-	end
-
-	local SaveProfile = CreateMenuButton(window, window:GetWidth()-10, 20, "New Profile", "TOPLEFT", EnableAll, "BOTTOMLEFT", 0, -5)
+	local SaveProfile = CreateMenuButton(window, window:GetWidth()-10, 20, L.New_Profile, "TOPLEFT", EnableAll, "BOTTOMLEFT", 0, -5)
 	SaveProfile:SetScript("OnClick", function(self)
 		if not self.editbox then
-			local ebox = CreateFrame("EditBox", nil, self)
-			SkinFrame(ebox)
-			ebox:SetAllPoints(self)
-			ebox:SetFont(unpack(font))
-			ebox:SetText("Profile Name")
-			ebox:SetAutoFocus(false)
-			ebox:SetFocus(true)
-			ebox:HighlightText()
-			ebox:SetTextInsets(3, 0, 0, 0)
-			ebox:SetScript("OnEditFocusGained", function(self) self:HighlightText() end)
-			ebox:SetScript("OnEscapePressed", function(self) self:SetText("Profile Name") self:ClearFocus() self:Hide() end)
-			ebox:SetScript("OnEnterPressed", function(self)
+			local editbox = CreateFrame("EditBox", nil, self)
+			SkinFrame(editbox)
+			editbox:SetAllPoints(self)
+			editbox:SetFont(unpack(font))
+			editbox:SetText(L.Profile_Name)
+			editbox:SetAutoFocus(false)
+			editbox:SetFocus(true)
+			editbox:HighlightText()
+			editbox:SetTextInsets(3, 0, 0, 0)
+			editbox:SetScript("OnEditFocusGained", function(self) self:HighlightText() end)
+			editbox:SetScript("OnEscapePressed", function(self) self:SetText(L.Profile_Name) self:ClearFocus() self:Hide() end)
+			editbox:SetScript("OnEnterPressed", function(self)
 				local profileName = self:GetText()
 				self:ClearFocus()
-				self:SetText("Profile Name")
+				self:SetText(L.Profile_Name)
 				self:Hide()
 				if not profileName then return end
 				stAddonProfiles[profileName] = GetEnabledAddons()
 				stAddonManager:UpdateProfileList()
 			end)

-			self.editbox = ebox
+			self.editbox = editbox
 		else
 			self.editbox:Show()
 			self.editbox:SetFocus(true)
@@ -237,13 +242,12 @@ function stAddonManager:LoadProfileWindow()
 	self:SetScript("OnHide", function(self)
 		if self.SaveProfile.editbox then self.SaveProfile.editbox:Hide() end
 		window:Hide()
-		-- self.profileButton.text:SetText(">")
 	end)

 	local buttons = {}
 	function stAddonManager:UpdateProfileList()
-		local i = 1

+		--Thanks for hydra for this sort code
 		local sort = function(t, func)
 			local temp = {}
 			local i = 0
@@ -266,45 +270,46 @@ function stAddonManager:LoadProfileWindow()
 			return iter
 		end

+		local function CollapseAllProfiles()
+			for i=1, #buttons do
+				buttons[i].overlay:Hide()
+				buttons[i]:SetHeight(20)
+			end
+		end
+
 		for i=1, #buttons do
 			buttons[i]:Hide()
-			buttons[i].overlay:Hide()
-			buttons[i]:SetHeight(20)
+			CollapseAllProfiles()
 		end

+		local i = 1
 		for profileName, addonList in sort(stAddonProfiles, function(a, b) return strlower(b) > strlower(a) end) do
 			if not buttons[i] then
-				local button = CreateMenuButton(window, window:GetWidth()-10, 20, "<Profile Name>")
+				local button = CreateMenuButton(window, window:GetWidth()-10, 20, "<"..L.Profile_Name..">")
 				button.text:ClearAllPoints()
 				button.text:SetPoint("CENTER", button, "TOP", 0, -10)

 				local overlay = CreateFrame("Frame", nil, button)
-				overlay:EnableMouse(true) --just to stop the mouseover highlight when your mouse goes between the buttons
-				overlay:SetPoint("BOTTOM", button, "BOTTOM", 0, 3)
+				overlay:SetHeight(1)
 				overlay:SetPoint("TOP", button, "TOP", 0, -18)
 				overlay:SetWidth(button:GetWidth()-10)
 				overlay:SetFrameLevel(button:GetFrameLevel()+1)
 				overlay:Hide()

-				overlay.set = CreateMenuButton(overlay, overlay:GetWidth(), 20, "Set to..", "TOP", overlay, "TOP", 0, 0)
-				overlay.add = CreateMenuButton(overlay, overlay:GetWidth(), 20, "Add to..", "TOP", overlay.set, "BOTTOM", 0, 1)
-				overlay.remove = CreateMenuButton(overlay, overlay:GetWidth(), 20, "Remove from..", "TOP", overlay.add, "BOTTOM", 0, 1)
-				overlay.delete = CreateMenuButton(overlay, overlay:GetWidth(), 20, "Delete Profile", "TOP", overlay.remove, "BOTTOM", 0, 1)
+				overlay.set = CreateMenuButton(overlay, overlay:GetWidth(), 20, L.Set_To, "TOP", button, "TOP", 0, -18)
+				overlay.add = CreateMenuButton(overlay, overlay:GetWidth(), 20, L.Add_To, "TOP", overlay.set, "BOTTOM", 0, 1)
+				overlay.remove = CreateMenuButton(overlay, overlay:GetWidth(), 20, L.Remove_From, "TOP", overlay.add, "BOTTOM", 0, 1)
+				overlay.delete = CreateMenuButton(overlay, overlay:GetWidth(), 20, L.Delete_Profile, "TOP", overlay.remove, "BOTTOM", 0, 1)

 				button.overlay = overlay

 				button:SetScript("OnClick", function(self)
+
+
 					if self.overlay:IsShown() then
-						for i=1, #buttons do
-							buttons[i].overlay:Hide()
-							buttons[i]:SetHeight(20)
-						end
+						CollapseAllProfiles()
 					else
-						for i=1, #buttons do
-							buttons[i].overlay:Hide()
-							buttons[i]:SetHeight(20)
-						end
-
+						CollapseAllProfiles()
 						self.overlay:Show()
 						self:SetHeight(20*5)
 					end
@@ -322,48 +327,33 @@ function stAddonManager:LoadProfileWindow()
 				for i, name in pairs(addonList) do EnableAddOn(name) end
 				stAddonManager.AllAddons = stAddonManager:UpdateAddonList()
 				stAddonManager:UpdateList(stAddonManager.AllAddons)
-				for i=1, #buttons do
-					buttons[i].overlay:Hide()
-					buttons[i]:SetHeight(20)
-				end
+				CollapseAllProfiles()
 			end)
 			overlay.add:SetScript("OnClick", function(self)
 				for i, name in pairs(addonList) do EnableAddOn(name) end
 				stAddonManager.AllAddons = stAddonManager:UpdateAddonList()
 				stAddonManager:UpdateList(stAddonManager.AllAddons)
-				for i=1, #buttons do
-					buttons[i].overlay:Hide()
-					buttons[i]:SetHeight(20)
-				end
+				CollapseAllProfiles()
 			end)
 			overlay.remove:SetScript("OnClick", function(self)
 				for i, name in pairs(addonList) do if name ~= ADDON_NAME then DisableAddOn(name) end end
 				stAddonManager.AllAddons = stAddonManager:UpdateAddonList()
 				stAddonManager:UpdateList(stAddonManager.AllAddons)
-				for i=1, #buttons do
-					buttons[i].overlay:Hide()
-					buttons[i]:SetHeight(20)
-				end
+				CollapseAllProfiles()
 			end)
 			overlay.delete:SetScript("OnClick", function(self)
 				if IsShiftKeyDown() then
 					stAddonProfiles[profileName] = nil
 					stAddonManager:UpdateProfileList()
-					for i=1, #buttons do
-						buttons[i].overlay:Hide()
-						buttons[i]:SetHeight(20)
-					end
+					CollapseAllProfiles()
 				else
-					print("|cff00aaffst|rAddonManager: Are you sure you want to delete this profile? Hold down shift and click again if you are.")
+					print("|cff00aaffst|rAddonManager: "..L.Confirm_Delete)
 				end
-
 			end)
-
 			i = i + 1
 		end

 		local prevButton
-		local lastButton
 		for i,button in pairs(buttons) do
 			if i == 1 then
 				button:SetPoint("TOP", SaveProfile, "BOTTOM", 0, -5)
@@ -378,9 +368,9 @@ function stAddonManager:LoadProfileWindow()
 		window.backdrop:SetPoint("TOPRIGHT", window, "TOPRIGHT", 0, 0)
 		window.backdrop:SetPoint("BOTTOM", prevButton, "BOTTOM", 0, -5)
 	end
-	stAddonManager:UpdateProfileList()
-
 	self.ProfileWindow = window
+
+	stAddonManager:UpdateProfileList()
 end

 function stAddonManager:LoadWindow()
@@ -528,15 +518,15 @@ function stAddonManager:LoadWindow()
 	local searchBar = CreateFrame("EditBox", window:GetName().."_SearchBar", window)
 	searchBar:SetFrameLevel(window:GetFrameLevel()+1)
 	searchBar:SetPoint("TOPLEFT", header, "BOTTOMLEFT", 10, -5)
-	searchBar:SetWidth(130)
+	searchBar:SetWidth(150)
 	searchBar:SetHeight(20)
 	SkinFrame(searchBar)
 	searchBar:SetFont(unpack(font))
-	searchBar:SetText("Search")
+	searchBar:SetText(L.Search)
 	searchBar:SetAutoFocus(false)
 	searchBar:SetTextInsets(3, 0, 0 ,0)
 	searchBar:SetScript("OnEnterPressed", function(self) self:ClearFocus() end)
-	searchBar:SetScript("OnEscapePressed", function(self) searchBar:SetText("Search") stAddonManager:UpdateList(stAddonManager.AllAddons) searchBar:ClearFocus() end)
+	searchBar:SetScript("OnEscapePressed", function(self) searchBar:SetText(L.Search) stAddonManager:UpdateList(stAddonManager.AllAddons) searchBar:ClearFocus() end)
 	searchBar:SetScript("OnEditFocusGained", function(self) self:HighlightText() end)
 	searchBar:SetScript("OnTextChanged", function(self, input)
 		if input then
@@ -555,22 +545,17 @@ function stAddonManager:LoadWindow()
 	sbClear.text:SetPoint("CENTER", sbClear, "CENTER", 0, 0)
 	sbClear:SetScript("OnEnter", function(self) self.text:SetTextColor(0/255, 170/255, 255/255) end)
 	sbClear:SetScript("OnLeave", function(self) self.text:SetTextColor(255/255, 255/255, 255/255) end)
-	sbClear:SetScript("OnClick", function(self) searchBar:SetText("Search") stAddonManager:UpdateList(stAddonManager.AllAddons) searchBar:ClearFocus() end)
+	sbClear:SetScript("OnClick", function(self) searchBar:SetText(L.Search) stAddonManager:UpdateList(stAddonManager.AllAddons) searchBar:ClearFocus() end)
 	searchBar.clear = sbClear
 	stAddonManager.searchBar = searchBar

-	local profileButton = CreateMenuButton(window, 80, 20, "Profiles", "TOPRIGHT", header, "BOTTOMRIGHT", -10, -5)
+	local profileButton = CreateMenuButton(window, 50, 20, L.Profiles, "TOPRIGHT", header, "BOTTOMRIGHT", -10, -5)
 	profileButton:SetScript("OnClick", function(self)
 		stAddonManager:LoadProfileWindow()
-		-- if stAddonManager.ProfileWindow:IsShown() then
-			-- self.text:SetText("<")
-		-- else
-			-- self.text:SetText(">")
-		-- end
 	end)
 	stAddonManager.profileButton = profileButton

-	local reloadButton = CreateMenuButton(window, 1, searchBar:GetHeight(), "Reload UI", "LEFT", searchBar, "RIGHT", 5, 0)
+	local reloadButton = CreateMenuButton(window, 1, searchBar:GetHeight(), L.ReloadUI, "LEFT", searchBar, "RIGHT", 5, 0)
 	reloadButton:SetPoint("RIGHT", profileButton, "LEFT", -5, 0)
 	reloadButton:SetScript("OnClick", function(self)
 		if InCombatLockdown() then return end
diff --git a/stAddonManager.toc b/stAddonManager.toc
index 2a4e1a2..7878977 100644
--- a/stAddonManager.toc
+++ b/stAddonManager.toc
@@ -5,4 +5,5 @@
 ## Notes: A simple and minimalistic addon to disable/enabled addons without logging out.
 ## SavedVariables: stAddonProfiles, stLockedAddons

+localization.lua
 stAddonManager.lua
\ No newline at end of file