diff --git a/Checklist.lua b/Checklist.lua index 8aa3d26..c7fa69f 100644 --- a/Checklist.lua +++ b/Checklist.lua @@ -11,6 +11,7 @@ local Constants = addon.Constants local Utils = addon.Utils local UI = addon.UI local Data = addon.Data +local L = LibStub("AceLocale-3.0"):GetLocale(addonName) function Checklist:ToggleWindow() if not self.window then return end @@ -81,7 +82,7 @@ function Checklist:Render() self.window.titlebar.title:SetPoint("LEFT", self.window.titlebar, 28, 0) self.window.titlebar.title:SetJustifyH("LEFT") self.window.titlebar.title:SetJustifyV("MIDDLE") - self.window.titlebar.title:SetText("Checklist") + self.window.titlebar.title:SetText(L["label_checklist"]) self.window.textbox = self.window:CreateFontString("$parentTextbox", "ARTWORK") self.window.textbox:SetFontObject("SystemFont_Med1") @@ -100,7 +101,7 @@ function Checklist:Render() self.window.titlebar.closeButton.Icon:SetVertexColor(1, 1, 1, 1) Utils:SetBackgroundColor(self.window.titlebar.closeButton, 1, 0, 0, 0.2) GameTooltip:SetOwner(self.window.titlebar.closeButton, "ANCHOR_TOP") - GameTooltip:SetText("Close the window", 1, 1, 1, 1, true); + GameTooltip:SetText(L["tooltip_close_window"], 1, 1, 1, 1, true); GameTooltip:Show() end) self.window.titlebar.closeButton:SetScript("OnLeave", function() @@ -125,8 +126,8 @@ function Checklist:Render() Utils:SetBackgroundColor(self.window.titlebar.SettingsButton, 1, 1, 1, 0.05) ---@diagnostic disable-next-line: param-type-mismatch GameTooltip:SetOwner(self.window.titlebar.SettingsButton, "ANCHOR_TOP") - GameTooltip:SetText("Settings", 1, 1, 1, 1, true); - GameTooltip:AddLine("Let's customize things a bit", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); + GameTooltip:SetText(L["label_settings"], 1, 1, 1, 1, true); + GameTooltip:AddLine(L["tooltip_customize"], NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); GameTooltip:Show() end) self.window.titlebar.SettingsButton:SetScript("OnLeave", function() @@ -136,7 +137,7 @@ function Checklist:Render() end) self.window.titlebar.SettingsButton:SetupMenu(function(_, rootMenu) local showFullProfessionName = rootMenu:CreateCheckbox( - "Show full profession name", + L["button_show_full_profession_name"], function() return Data.db.global.showFullProfessionName end, function() Data.db.global.showFullProfessionName = not Data.db.global.showFullProfessionName @@ -148,11 +149,11 @@ function Checklist:Render() ) showFullProfessionName:SetTooltip(function(tooltip, elementDescription) GameTooltip_SetTitle(tooltip, MenuUtil.GetElementText(elementDescription)); - GameTooltip_AddNormalLine(tooltip, "Show the full profession name with the expansion variant."); + GameTooltip_AddNormalLine(tooltip, L["tooltip_show_full_profession_name"]); end) rootMenu:CreateCheckbox( - "Hide in combat", + L["menu_hide_in_combat"], function() return Data.db.global.checklist.hideInCombat end, function() Data.db.global.checklist.hideInCombat = not Data.db.global.checklist.hideInCombat @@ -160,7 +161,7 @@ function Checklist:Render() end ) rootMenu:CreateCheckbox( - "Hide in dungeons", + L["menu_hide_in_dungeons"], function() return Data.db.global.checklist.hideInDungeons end, function() Data.db.global.checklist.hideInDungeons = not Data.db.global.checklist.hideInDungeons @@ -168,15 +169,15 @@ function Checklist:Render() end ) rootMenu:CreateCheckbox( - "Hide completed objectives", + L["menu_hide_completed_objectives"], function() return Data.db.global.checklist.hideCompletedObjectives end, function() Data.db.global.checklist.hideCompletedObjectives = not Data.db.global.checklist.hideCompletedObjectives self:Render() end ) - rootMenu:CreateTitle("Window") - local windowScale = rootMenu:CreateButton("Scaling") + rootMenu:CreateTitle(L["label_window"]) + local windowScale = rootMenu:CreateButton(L["button_scaling"]) for i = 80, 200, 10 do windowScale:CreateRadio( i .. "%", @@ -222,7 +223,7 @@ function Checklist:Render() hasOpacity = 1, } rootMenu:CreateColorSwatch( - "Background color", + L["button_background_color"], function() ColorPickerFrame:SetupColorPickerAndShow(colorInfo) end, @@ -230,7 +231,7 @@ function Checklist:Render() ) rootMenu:CreateCheckbox( - "Show the border", + L["button_show_border"], function() return Data.db.global.checklist.windowBorder end, function() Data.db.global.checklist.windowBorder = not Data.db.global.checklist.windowBorder @@ -263,8 +264,8 @@ function Checklist:Render() Utils:SetBackgroundColor(self.window.titlebar.ExpansionButton, 1, 1, 1, 0.05) ---@diagnostic disable-next-line: param-type-mismatch GameTooltip:SetOwner(self.window.titlebar.ExpansionButton, "ANCHOR_TOP") - GameTooltip:SetText("Expansion", 1, 1, 1, 1, true) - GameTooltip:AddLine("Filter table by expansion.", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b) + GameTooltip:SetText(L["label_expansion"], 1, 1, 1, 1, true) + GameTooltip:AddLine(L["tooltip_expansion_filter_checklist"], NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b) GameTooltip:Show() end) self.window.titlebar.ExpansionButton:SetScript("OnLeave", function() @@ -301,8 +302,8 @@ function Checklist:Render() Utils:SetBackgroundColor(self.window.titlebar.ColumnsButton, 1, 1, 1, 0.05) ---@diagnostic disable-next-line: param-type-mismatch GameTooltip:SetOwner(self.window.titlebar.ColumnsButton, "ANCHOR_TOP") - GameTooltip:SetText("Columns", 1, 1, 1, 1, true); - GameTooltip:AddLine("Toggle columns.", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); + GameTooltip:SetText(L["label_columns"], 1, 1, 1, 1, true); + GameTooltip:AddLine(L["tooltip_columns_checklist"], NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); GameTooltip:Show() end) self.window.titlebar.ColumnsButton:SetScript("OnLeave", function() @@ -342,8 +343,8 @@ function Checklist:Render() Utils:SetBackgroundColor(self.window.titlebar.CategoriesButton, 1, 1, 1, 0.05) ---@diagnostic disable-next-line: param-type-mismatch GameTooltip:SetOwner(self.window.titlebar.CategoriesButton, "ANCHOR_TOP") - GameTooltip:SetText("Categories", 1, 1, 1, 1, true); - GameTooltip:AddLine("Toggle categories.", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); + GameTooltip:SetText(L["label_categories"], 1, 1, 1, 1, true); + GameTooltip:AddLine(L["tooltip_categories"], NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); GameTooltip:Show() end) self.window.titlebar.CategoriesButton:SetScript("OnLeave", function() @@ -385,8 +386,8 @@ function Checklist:Render() self.window.titlebar.toggleButton.Icon:SetVertexColor(0.9, 0.9, 0.9, 1) Utils:SetBackgroundColor(self.window.titlebar.toggleButton, 1, 1, 1, 0.05) GameTooltip:SetOwner(self.window.titlebar.toggleButton, "ANCHOR_TOP") - GameTooltip:SetText("Toggle List", 1, 1, 1, 1, true) - GameTooltip:AddLine("Expand/Collapse the checklist.", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); + GameTooltip:SetText(L["label_toggle_list"], 1, 1, 1, 1, true) + GameTooltip:AddLine(L["tooltip_toggle_list"], NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); GameTooltip:Show() end) self.window.titlebar.toggleButton:SetScript("OnLeave", function() @@ -565,7 +566,7 @@ function Checklist:Render() self.window.textbox:Hide() else if rowCount == 0 then - self.window.textbox:SetText("It does not look like you have any active professions.\nDid you maybe filter out the wrong expansion or category above?\n\nIf this is your first time using this addon then make sure to open your professions at least once.") + self.window.textbox:SetText(L["checklist_empty_state"]) windowHeight = 200 self.window.textbox:Show() self.window.table:Hide() @@ -599,11 +600,11 @@ function Checklist:GetColumns(unfiltered) ---@type WK_ChecklistColumn[] local columns = { { - name = "Objective", + name = L["label_objective"], width = 260, cell = function(data) if data.objective.itemID and data.objective.itemID > 0 then - local text = format("Error: ItemID %d not found", data.objective.itemID or "?") + local text = format(L["error_item_not_found"], data.objective.itemID or "?") local link = "" -- Todo: Cache/Re-render item info local itemName, itemLink, _, _, _, _, _, _, _, itemTexture = C_Item.GetItemInfo(data.objective.itemID) @@ -624,7 +625,7 @@ function Checklist:GetColumns(unfiltered) GameTooltip:SetOwner(columnFrame, "ANCHOR_RIGHT") GameTooltip:SetHyperlink(link) GameTooltip:AddLine(" ") - GameTooltip:AddLine("", GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) + GameTooltip:AddLine(L["tooltip_link_chat"], GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) GameTooltip:Show() end end, @@ -642,7 +643,7 @@ function Checklist:GetColumns(unfiltered) end, } elseif data.objective.categoryID == Enum.WK_ObjectiveCategory.FirstCraft then - local text = format("Error: RecipeID %d not found", data.objective.spellID or "?") + local text = format(L["error_recipe_not_found"], data.objective.spellID or "?") local link = "" local recipeInfo = Data.cache.tradeSkillRecipes and Data.cache.tradeSkillRecipes[data.objective.spellID] if not recipeInfo then @@ -665,8 +666,8 @@ function Checklist:GetColumns(unfiltered) GameTooltip:SetOwner(columnFrame, "ANCHOR_RIGHT") GameTooltip:SetHyperlink(link) GameTooltip:AddLine(" ") - GameTooltip:AddLine("", GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) - GameTooltip:AddLine("", GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) + GameTooltip:AddLine(L["tooltip_click_open_recipe"], GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) + GameTooltip:AddLine(L["tooltip_link_chat"], GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) GameTooltip:Show() end end, @@ -686,7 +687,7 @@ function Checklist:GetColumns(unfiltered) end, } elseif data.objective.quests and Utils:TableCount(data.objective.quests) > 0 then - local text = format("Error: QuestID %d not found", data.objective.quests[1] or "?") + local text = format(L["error_quest_not_found"], data.objective.quests[1] or "?") local link = format("quest:%d:-1", data.objective.quests[1]) local questTooltipData = C_TooltipInfo.GetHyperlink(link) if questTooltipData and questTooltipData.lines and questTooltipData.lines[1] and questTooltipData.lines[1].leftText then @@ -699,7 +700,7 @@ function Checklist:GetColumns(unfiltered) GameTooltip:SetOwner(columnFrame, "ANCHOR_RIGHT") GameTooltip:SetHyperlink(link) GameTooltip:AddLine(" ") - GameTooltip:AddLine("", GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) + GameTooltip:AddLine(L["tooltip_link_chat"], GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) GameTooltip:Show() end end, @@ -717,7 +718,7 @@ function Checklist:GetColumns(unfiltered) end, } else - local text = "Unknown" + local text = L["label_unknown"] return { text = text, } @@ -725,7 +726,7 @@ function Checklist:GetColumns(unfiltered) end, }, { - name = "Profession", + name = L["label_profession"], width = Data.db.global.showFullProfessionName and 160 or 100, toggleHidden = true, cell = function(data) @@ -743,7 +744,7 @@ function Checklist:GetColumns(unfiltered) onEnter = function(cellFrame) GameTooltip:SetOwner(cellFrame, "ANCHOR_RIGHT") GameTooltip:SetText(text, 1, 1, 1); - GameTooltip:AddLine(format(""), GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) + GameTooltip:AddLine(L["tooltip_click_open_profession"], GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) GameTooltip:Show() end, onLeave = function() @@ -756,7 +757,7 @@ function Checklist:GetColumns(unfiltered) end, }, { - name = "Expansion", + name = L["label_expansion"], width = 120, toggleHidden = true, cell = function(data) @@ -768,7 +769,7 @@ function Checklist:GetColumns(unfiltered) end, }, { - name = "Category", + name = L["label_category"], width = 80, toggleHidden = true, cell = function(data) @@ -793,7 +794,7 @@ function Checklist:GetColumns(unfiltered) end, }, { - name = "Location", + name = L["label_location"], width = 100, toggleHidden = true, cell = function(data) @@ -815,7 +816,7 @@ function Checklist:GetColumns(unfiltered) end, }, { - name = "Repeat?", + name = L["label_repeat"], width = 60, toggleHidden = true, cell = function(data) @@ -837,7 +838,7 @@ function Checklist:GetColumns(unfiltered) end, }, { - name = "Progress", + name = L["label_progress"], width = 70, align = "CENTER", toggleHidden = true, @@ -853,7 +854,7 @@ function Checklist:GetColumns(unfiltered) end, }, { - name = "Points", + name = L["label_points"], width = 70, align = "CENTER", toggleHidden = true, @@ -890,7 +891,7 @@ function Checklist:GetColumns(unfiltered) onEnter = function(columnFrame) local showTooltip = function() GameTooltip:SetOwner(columnFrame, "ANCHOR_RIGHT") - GameTooltip:SetText("Do you know de wey?", 1, 1, 1) + GameTooltip:SetText(L["tooltip_do_you_know_de_wey"], 1, 1, 1) if data.objective.loc and data.objective.loc.hint then GameTooltip:AddLine(data.objective.loc.hint, nil, nil, nil, true) @@ -903,19 +904,19 @@ function Checklist:GetColumns(unfiltered) if mapInfo then GameTooltip:AddLine(" ") - GameTooltip:AddDoubleLine("Location:", mapInfo.name, nil, nil, nil, 1, 1, 1) + GameTooltip:AddDoubleLine(L["label_location_colon"], mapInfo.name, nil, nil, nil, 1, 1, 1) end if data.objective.loc and data.objective.loc.x then if not mapInfo then GameTooltip:AddLine(" ") end - GameTooltip:AddDoubleLine("Coordinates:", format("%.1f / %.1f", data.objective.loc.x, data.objective.loc.y), nil, nil, nil, 1, 1, 1) + GameTooltip:AddDoubleLine(L["label_coordinates"], format("%.1f / %.1f", data.objective.loc.x, data.objective.loc.y), nil, nil, nil, 1, 1, 1) end - local requirementsHeading = "Requirements:" + local requirementsHeading = L["label_requirements"] if data.objective.categoryID == Enum.WK_ObjectiveCategory.CatchUp then - requirementsHeading = "Unlock Catch-Up This Week:" + requirementsHeading = L["label_unlock_catch_up"] end -- Requirements @@ -930,12 +931,12 @@ function Checklist:GetColumns(unfiltered) -- Item Rewards if Utils:TableCount(data.progress.items) > 0 then GameTooltip:AddLine(" ") - GameTooltip:AddLine("Rewards:") + GameTooltip:AddLine(L["label_rewards"]) Utils:TableForEach(data.progress.items, function(isLooted, itemID) local item = Data.cache.items[itemID] local itemCached = item and item:IsItemDataCached() local icon = itemCached and item:GetItemIcon() or 134400 - local name = itemCached and item:GetItemLink() or "Loading..." + local name = itemCached and item:GetItemLink() or L["label_loading"] if data.objective.categoryID == Enum.WK_ObjectiveCategory.CatchUp then GameTooltip:AddLine(format("%s %s", CreateSimpleTextureMarkup(icon, 13, 13), name), 1, 1, 1, true) else @@ -953,11 +954,11 @@ function Checklist:GetColumns(unfiltered) GameTooltip:AddLine(" ") end if C_Map.CanSetUserWaypointOnMap(data.objective.loc.m) then - GameTooltip:AddLine("", GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) - GameTooltip:AddLine("", GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) + GameTooltip:AddLine(L["tooltip_click_map_pin"], GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) + GameTooltip:AddLine(L["tooltip_link_map_pin"], GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) end if TomTomGlobal then - GameTooltip:AddLine("", GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) + GameTooltip:AddLine(L["tooltip_place_tomtom"], GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b) end end GameTooltip:Show() @@ -989,7 +990,7 @@ function Checklist:GetColumns(unfiltered) onClick = function() if mapPoint then if IsAltKeyDown() and TomTomGlobal then - local text = "Objective" + local text = L["label_objective_pin"] TomTomGlobal:AddWaypoint(data.objective.loc.m, data.objective.loc.x / 100, data.objective.loc.y / 100, {title = text, from = addonName}) elseif C_Map.CanSetUserWaypointOnMap(data.objective.loc.m) then if IsModifiedClick("CHATLINK") then diff --git a/Core.lua b/Core.lua index 9a92a93..a26ed76 100644 --- a/Core.lua +++ b/Core.lua @@ -8,6 +8,7 @@ local Main = addon.Main local Checklist = addon.Checklist local LibDataBroker = LibStub("LibDataBroker-1.1") local LibDBIcon = LibStub("LibDBIcon-1.0") +local L = LibStub("AceLocale-3.0"):GetLocale(addonName) local Core = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceTimer-3.0", "AceEvent-3.0", "AceBucket-3.0") addon.Core = Core @@ -37,7 +38,7 @@ function Core:HandleCommand(message) if cmd:lower() == "minimap" then Data.db.global.minimap.hide = not Data.db.global.minimap.hide LibDBIcon:Refresh(addonName, Data.db.global.minimap) - self:Print("Minimap button " .. (Data.db.global.minimap.hide and "hidden" or "shown") .. ".") + self:Print(format(L["command_minimap_status"], L[Data.db.global.minimap.hide and "command_hidden" or "command_shown"])) self:Render() return end @@ -45,12 +46,12 @@ function Core:HandleCommand(message) Main:ToggleWindow() return end - self:Print("Usage: /wk [checklist | minimap]") + self:Print(L["command_usage"]) end function Core:OnInitialize() - _G["BINDING_NAME_WEEKLYKNOWLEDGE_MAIN"] = "Toggle WeeklyKnowledge window" - _G["BINDING_NAME_WEEKLYKNOWLEDGE_CHECKLIST"] = "Toggle Checklist window" + _G["BINDING_NAME_WEEKLYKNOWLEDGE_MAIN"] = L["binding_toggle_main"] + _G["BINDING_NAME_WEEKLYKNOWLEDGE_CHECKLIST"] = L["binding_toggle_checklist"] _G["WEEKLYKNOWLEDGE_TOGGLE_MAIN"] = function() if addon and addon.Main then addon.Main:ToggleWindow() end end @@ -63,7 +64,7 @@ function Core:OnInitialize() Data:InitDB() Data:MigrateDB() if Data:TaskWeeklyReset() then - self:Print("Weekly Reset: Good job! Progress of your characters have been reset for a new week.") + self:Print(L["prompt_weekly_reset"]) end local WKLDB = LibDataBroker:NewDataObject(addonName, { @@ -80,11 +81,11 @@ function Core:OnInitialize() end, OnTooltipShow = function(tooltip) tooltip:SetText(addonName, 1, 1, 1) - tooltip:AddLine("|cff00ff00Left click|r to open WeeklyKnowledge.", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b) - tooltip:AddLine("|cff00ff00Right click|r to open the Checklist.", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b) - local dragText = "|cff00ff00Drag|r to move this icon" + tooltip:AddLine(GREEN_FONT_COLOR:WrapTextInColorCode(L["command_left_click"]) .. " " .. L["tooltip_left_click_open"], NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b) + tooltip:AddLine(GREEN_FONT_COLOR:WrapTextInColorCode(L["command_right_click"]) .. " " .. L["tooltip_right_click_open"], NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b) + local dragText = GREEN_FONT_COLOR:WrapTextInColorCode(L["command_drag"]) .. " " .. L["tooltip_drag_minimap"] if Data.db.global.minimap.lock then - dragText = dragText .. " |cffff0000(locked)|r" + dragText = dragText .. " " .. RED_FONT_COLOR:WrapTextInColorCode(L["command_locked"]) end tooltip:AddLine(dragText .. ".", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b) end diff --git a/Data/Expansions.lua b/Data/Expansions.lua index 94331b1..6f4029c 100644 --- a/Data/Expansions.lua +++ b/Data/Expansions.lua @@ -5,10 +5,11 @@ local addon = select(2, ...) ---@class WK_Data local Data = addon.Data +local L = LibStub("AceLocale-3.0"):GetLocale(addonName) ---@type WK_Expansion[] Data.Expansions = { - {id = Enum.ExpansionLevel.Dragonflight, enabled = false, abbr = "DF", name = "Dragonflight"}, -- Disable for now since it's not set up yet. - {id = Enum.ExpansionLevel.WarWithin, enabled = true, abbr = "TWW", name = "The War Within"}, - {id = Enum.ExpansionLevel.Midnight, enabled = true, abbr = "Midnight", name = "Midnight"}, + {id = Enum.ExpansionLevel.Dragonflight, enabled = false, abbr = "DF", name = L["expansion_dragonflight"]}, -- Disable for now since it's not set up yet. + {id = Enum.ExpansionLevel.WarWithin, enabled = true, abbr = "TWW", name = L["expansion_war_within"]}, + {id = Enum.ExpansionLevel.Midnight, enabled = true, abbr = "Midnight", name = L["expansion_midnight"]}, } diff --git a/Data/ObjectiveCategories.lua b/Data/ObjectiveCategories.lua index e7cbb1b..4c4d798 100644 --- a/Data/ObjectiveCategories.lua +++ b/Data/ObjectiveCategories.lua @@ -5,15 +5,16 @@ local addon = select(2, ...) ---@class WK_Data local Data = addon.Data +local L = LibStub("AceLocale-3.0"):GetLocale(addonName) ---@type WK_ObjectiveCategory[] Data.ObjectiveCategories = { - {id = Enum.WK_ObjectiveCategory.Unique, name = "Uniques", description = "These are one-time items found in treasures around the world and sold by vendors.\n\nRepeatable: " .. WHITE_FONT_COLOR:WrapTextInColorCode("No"), type = "item", repeatable = "No",}, - {id = Enum.WK_ObjectiveCategory.FirstCraft, name = "First Craft", description = "These are your first craft or first gathering bonuses.\n\nNote: Not every profession or expansion is updated yet.\n\nRepeatable: " .. WHITE_FONT_COLOR:WrapTextInColorCode("No"), type = "recipe", repeatable = "No",}, - {id = Enum.WK_ObjectiveCategory.Treatise, name = "Treatise", description = "These can be crafted with Inscription. Send a Crafting Order if you don't have the profession.\n\nRepeatable: " .. WHITE_FONT_COLOR:WrapTextInColorCode("Weekly"), type = "item", repeatable = "Weekly", hint = true,}, - {id = Enum.WK_ObjectiveCategory.WeeklyQuest, name = "Weekly Quest", description = "Complete a quest from your profession trainer or from the Artisan's Consortium.\n\nRepeatable: " .. WHITE_FONT_COLOR:WrapTextInColorCode("Weekly"), type = "quest", repeatable = "Weekly",}, - {id = Enum.WK_ObjectiveCategory.Treasure, name = "Treasure", description = "These are randomly looted from treasures around the world.\n\nRepeatable: " .. WHITE_FONT_COLOR:WrapTextInColorCode("Weekly"), type = "item", repeatable = "Weekly", hint = true,}, - {id = Enum.WK_ObjectiveCategory.Gathering, name = "Gathering", description = "These are randomly looted from gathering nodes around the world.\n\nFor Enchanting these are looted from Disenchanting.\n\nRepeatable: " .. WHITE_FONT_COLOR:WrapTextInColorCode("Weekly"), type = "item", repeatable = "Weekly",}, - {id = Enum.WK_ObjectiveCategory.DarkmoonQuest, name = "Darkmoon", description = "Complete a quest at the Darkmoon Faire.\n\nRepeatable: " .. WHITE_FONT_COLOR:WrapTextInColorCode("Monthly"), type = "quest", repeatable = "Monthly",}, - {id = Enum.WK_ObjectiveCategory.CatchUp, name = "Catch-Up", description = "Keep track of your catch-up points.\n\nYou will be able to gain these points once you've completed some of the other objectives.\n\nRepeatable: " .. WHITE_FONT_COLOR:WrapTextInColorCode("Yes"), type = "item", repeatable = "Yes",}, + {id = Enum.WK_ObjectiveCategory.Unique, name = L["category_uniques"], description = format(L["objective_desc_uniques"], WHITE_FONT_COLOR:WrapTextInColorCode(L["label_no"])), type = "item", repeatable = L["label_no"],}, + {id = Enum.WK_ObjectiveCategory.FirstCraft, name = L["category_first_craft"], description = format(L["objective_desc_first_craft"], WHITE_FONT_COLOR:WrapTextInColorCode(L["label_no"])), type = "recipe", repeatable = L["label_no"],}, + {id = Enum.WK_ObjectiveCategory.Treatise, name = L["category_treatise"], description = format(L["objective_desc_treatise"], WHITE_FONT_COLOR:WrapTextInColorCode(L["label_weekly"])), type = "item", repeatable = L["label_weekly"], hint = true,}, + {id = Enum.WK_ObjectiveCategory.WeeklyQuest, name = L["category_weekly_quest"], description = format(L["objective_desc_weekly_quest"], WHITE_FONT_COLOR:WrapTextInColorCode(L["label_weekly"])), type = "quest", repeatable = L["label_weekly"],}, + {id = Enum.WK_ObjectiveCategory.Treasure, name = L["category_treasure"], description = format(L["objective_desc_treasure"], WHITE_FONT_COLOR:WrapTextInColorCode(L["label_weekly"])), type = "item", repeatable = L["label_weekly"], hint = true,}, + {id = Enum.WK_ObjectiveCategory.Gathering, name = L["category_gathering"], description = format(L["objective_desc_gathering"], WHITE_FONT_COLOR:WrapTextInColorCode(L["label_weekly"])), type = "item", repeatable = L["label_weekly"],}, + {id = Enum.WK_ObjectiveCategory.DarkmoonQuest, name = L["category_darkmoon"], description = format(L["objective_desc_darkmoon"], WHITE_FONT_COLOR:WrapTextInColorCode(L["label_monthly"])), type = "quest", repeatable = L["label_monthly"],}, + {id = Enum.WK_ObjectiveCategory.CatchUp, name = L["category_catch_up"], description = format(L["objective_desc_catch_up"], WHITE_FONT_COLOR:WrapTextInColorCode(L["label_yes"])), type = "item", repeatable = L["label_yes"],}, } diff --git a/Data/SkillLineVariants.lua b/Data/SkillLineVariants.lua index 0f8926c..0119380 100644 --- a/Data/SkillLineVariants.lua +++ b/Data/SkillLineVariants.lua @@ -5,43 +5,44 @@ local addon = select(2, ...) ---@class WK_Data local Data = addon.Data +local L = LibStub("AceLocale-3.0"):GetLocale(addonName) ---@type WK_SkillLineVariant[] Data.SkillLineVariants = { -- Dragonflight (Dragon Isles) - {id = 2823, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 171, name = "Dragon Isles Alchemy", catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3054 - {id = 2822, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 164, name = "Dragon Isles Blacksmithing", catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3050 - {id = 2825, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 333, name = "Dragon Isles Enchanting", catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3051 - {id = 2827, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 202, name = "Dragon Isles Engineering", catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3052 - {id = 2832, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 182, name = "Dragon Isles Herbalism", catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, - {id = 2828, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 773, name = "Dragon Isles Inscription", catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3053 - {id = 2829, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 755, name = "Dragon Isles Jewelcrafting", catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3047 - {id = 2830, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 165, name = "Dragon Isles Leatherworking", catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3049 - {id = 2833, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 186, name = "Dragon Isles Mining", catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, - {id = 2834, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 393, name = "Dragon Isles Skinning", catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, - {id = 2831, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 197, name = "Dragon Isles Tailoring", catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3048 + {id = 2823, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 171, name = L["variant_dragon_isles_alchemy"], catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3054 + {id = 2822, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 164, name = L["variant_dragon_isles_blacksmithing"], catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3050 + {id = 2825, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 333, name = L["variant_dragon_isles_enchanting"], catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3051 + {id = 2827, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 202, name = L["variant_dragon_isles_engineering"], catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3052 + {id = 2832, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 182, name = L["variant_dragon_isles_herbalism"], catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, + {id = 2828, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 773, name = L["variant_dragon_isles_inscription"], catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3053 + {id = 2829, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 755, name = L["variant_dragon_isles_jewelcrafting"], catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3047 + {id = 2830, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 165, name = L["variant_dragon_isles_leatherworking"], catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3049 + {id = 2833, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 186, name = L["variant_dragon_isles_mining"], catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, + {id = 2834, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 393, name = L["variant_dragon_isles_skinning"], catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, + {id = 2831, expansionID = Enum.ExpansionLevel.Dragonflight, skillLineID = 197, name = L["variant_dragon_isles_tailoring"], catchUpCurrencyID = 0, catchUpItemID = 0, concentrationCurrencyID = 0}, -- 3048 -- The War Within (Khaz Algar) - {id = 2871, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 171, name = "Khaz Algar Alchemy", catchUpCurrencyID = 3057, catchUpItemID = 228724, concentrationCurrencyID = 3045}, - {id = 2872, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 164, name = "Khaz Algar Blacksmithing", catchUpCurrencyID = 3058, catchUpItemID = 228726, concentrationCurrencyID = 3040}, - {id = 2874, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 333, name = "Khaz Algar Enchanting", catchUpCurrencyID = 3059, catchUpItemID = 227662, concentrationCurrencyID = 3046}, - {id = 2875, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 202, name = "Khaz Algar Engineering", catchUpCurrencyID = 3060, catchUpItemID = 228730, concentrationCurrencyID = 3044}, - {id = 2877, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 182, name = "Khaz Algar Herbalism", catchUpCurrencyID = 3061, catchUpItemID = 224835, concentrationCurrencyID = 0}, - {id = 2878, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 773, name = "Khaz Algar Inscription", catchUpCurrencyID = 3062, catchUpItemID = 228732, concentrationCurrencyID = 3043}, - {id = 2879, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 755, name = "Khaz Algar Jewelcrafting", catchUpCurrencyID = 3063, catchUpItemID = 228734, concentrationCurrencyID = 3013}, - {id = 2880, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 165, name = "Khaz Algar Leatherworking", catchUpCurrencyID = 3064, catchUpItemID = 228736, concentrationCurrencyID = 3042}, - {id = 2881, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 186, name = "Khaz Algar Mining", catchUpCurrencyID = 3065, catchUpItemID = 224838, concentrationCurrencyID = 0}, - {id = 2882, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 393, name = "Khaz Algar Skinning", catchUpCurrencyID = 3066, catchUpItemID = 224782, concentrationCurrencyID = 0}, - {id = 2883, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 197, name = "Khaz Algar Tailoring", catchUpCurrencyID = 3067, catchUpItemID = 228738, concentrationCurrencyID = 3041}, + {id = 2871, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 171, name = L["variant_khaz_algar_alchemy"], catchUpCurrencyID = 3057, catchUpItemID = 228724, concentrationCurrencyID = 3045}, + {id = 2872, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 164, name = L["variant_khaz_algar_blacksmithing"], catchUpCurrencyID = 3058, catchUpItemID = 228726, concentrationCurrencyID = 3040}, + {id = 2874, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 333, name = L["variant_khaz_algar_enchanting"], catchUpCurrencyID = 3059, catchUpItemID = 227662, concentrationCurrencyID = 3046}, + {id = 2875, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 202, name = L["variant_khaz_algar_engineering"], catchUpCurrencyID = 3060, catchUpItemID = 228730, concentrationCurrencyID = 3044}, + {id = 2877, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 182, name = L["variant_khaz_algar_herbalism"], catchUpCurrencyID = 3061, catchUpItemID = 224835, concentrationCurrencyID = 0}, + {id = 2878, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 773, name = L["variant_khaz_algar_inscription"], catchUpCurrencyID = 3062, catchUpItemID = 228732, concentrationCurrencyID = 3043}, + {id = 2879, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 755, name = L["variant_khaz_algar_jewelcrafting"], catchUpCurrencyID = 3063, catchUpItemID = 228734, concentrationCurrencyID = 3013}, + {id = 2880, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 165, name = L["variant_khaz_algar_leatherworking"], catchUpCurrencyID = 3064, catchUpItemID = 228736, concentrationCurrencyID = 3042}, + {id = 2881, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 186, name = L["variant_khaz_algar_mining"], catchUpCurrencyID = 3065, catchUpItemID = 224838, concentrationCurrencyID = 0}, + {id = 2882, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 393, name = L["variant_khaz_algar_skinning"], catchUpCurrencyID = 3066, catchUpItemID = 224782, concentrationCurrencyID = 0}, + {id = 2883, expansionID = Enum.ExpansionLevel.WarWithin, skillLineID = 197, name = L["variant_khaz_algar_tailoring"], catchUpCurrencyID = 3067, catchUpItemID = 228738, concentrationCurrencyID = 3041}, -- Midnight - {id = 2906, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 171, name = "Midnight Alchemy", catchUpCurrencyID = 3189, catchUpItemID = 246320, concentrationCurrencyID = 3161}, - {id = 2907, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 164, name = "Midnight Blacksmithing", catchUpCurrencyID = 3199, catchUpItemID = 246322, concentrationCurrencyID = 3162}, - {id = 2909, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 333, name = "Midnight Enchanting", catchUpCurrencyID = 3198, catchUpItemID = 267653, concentrationCurrencyID = 3163}, - {id = 2910, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 202, name = "Midnight Engineering", catchUpCurrencyID = 3197, catchUpItemID = 246326, concentrationCurrencyID = 3164}, - {id = 2912, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 182, name = "Midnight Herbalism", catchUpCurrencyID = 3196, catchUpItemID = 238467, concentrationCurrencyID = 0}, - {id = 2913, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 773, name = "Midnight Inscription", catchUpCurrencyID = 3195, catchUpItemID = 246328, concentrationCurrencyID = 3165}, - {id = 2914, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 755, name = "Midnight Jewelcrafting", catchUpCurrencyID = 3194, catchUpItemID = 246330, concentrationCurrencyID = 3166}, - {id = 2915, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 165, name = "Midnight Leatherworking", catchUpCurrencyID = 3193, catchUpItemID = 246332, concentrationCurrencyID = 3167}, - {id = 2916, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 186, name = "Midnight Mining", catchUpCurrencyID = 3192, catchUpItemID = 237507, concentrationCurrencyID = 0}, - {id = 2917, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 393, name = "Midnight Skinning", catchUpCurrencyID = 3191, catchUpItemID = 238627, concentrationCurrencyID = 0}, - {id = 2918, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 197, name = "Midnight Tailoring", catchUpCurrencyID = 3190, catchUpItemID = 246334, concentrationCurrencyID = 3168}, + {id = 2906, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 171, name = L["variant_midnight_alchemy"], catchUpCurrencyID = 3189, catchUpItemID = 246320, concentrationCurrencyID = 3161}, + {id = 2907, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 164, name = L["variant_midnight_blacksmithing"], catchUpCurrencyID = 3199, catchUpItemID = 246322, concentrationCurrencyID = 3162}, + {id = 2909, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 333, name = L["variant_midnight_enchanting"], catchUpCurrencyID = 3198, catchUpItemID = 267653, concentrationCurrencyID = 3163}, + {id = 2910, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 202, name = L["variant_midnight_engineering"], catchUpCurrencyID = 3197, catchUpItemID = 246326, concentrationCurrencyID = 3164}, + {id = 2912, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 182, name = L["variant_midnight_herbalism"], catchUpCurrencyID = 3196, catchUpItemID = 238467, concentrationCurrencyID = 0}, + {id = 2913, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 773, name = L["variant_midnight_inscription"], catchUpCurrencyID = 3195, catchUpItemID = 246328, concentrationCurrencyID = 3165}, + {id = 2914, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 755, name = L["variant_midnight_jewelcrafting"], catchUpCurrencyID = 3194, catchUpItemID = 246330, concentrationCurrencyID = 3166}, + {id = 2915, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 165, name = L["variant_midnight_leatherworking"], catchUpCurrencyID = 3193, catchUpItemID = 246332, concentrationCurrencyID = 3167}, + {id = 2916, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 186, name = L["variant_midnight_mining"], catchUpCurrencyID = 3192, catchUpItemID = 237507, concentrationCurrencyID = 0}, + {id = 2917, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 393, name = L["variant_midnight_skinning"], catchUpCurrencyID = 3191, catchUpItemID = 238627, concentrationCurrencyID = 0}, + {id = 2918, expansionID = Enum.ExpansionLevel.Midnight, skillLineID = 197, name = L["variant_midnight_tailoring"], catchUpCurrencyID = 3190, catchUpItemID = 246334, concentrationCurrencyID = 3168}, } diff --git a/Data/SkillLines.lua b/Data/SkillLines.lua index 895c166..cb349cc 100644 --- a/Data/SkillLines.lua +++ b/Data/SkillLines.lua @@ -5,18 +5,19 @@ local addon = select(2, ...) ---@class WK_Data local Data = addon.Data +local L = LibStub("AceLocale-3.0"):GetLocale(addonName) ---@type WK_SkillLine[] Data.SkillLines = { - {id = 171, name = "Alchemy"}, - {id = 164, name = "Blacksmithing"}, - {id = 333, name = "Enchanting"}, - {id = 202, name = "Engineering"}, - {id = 182, name = "Herbalism"}, - {id = 773, name = "Inscription"}, - {id = 755, name = "Jewelcrafting"}, - {id = 165, name = "Leatherworking"}, - {id = 186, name = "Mining"}, - {id = 393, name = "Skinning"}, - {id = 197, name = "Tailoring"}, + {id = 171, name = L["profession_alchemy"]}, + {id = 164, name = L["profession_blacksmithing"]}, + {id = 333, name = L["profession_enchanting"]}, + {id = 202, name = L["profession_engineering"]}, + {id = 182, name = L["profession_herbalism"]}, + {id = 773, name = L["profession_inscription"]}, + {id = 755, name = L["profession_jewelcrafting"]}, + {id = 165, name = L["profession_leatherworking"]}, + {id = 186, name = L["profession_mining"]}, + {id = 393, name = L["profession_skinning"]}, + {id = 197, name = L["profession_tailoring"]}, } diff --git a/Libs/AceLocale-3.0/AceLocale-3.0.lua b/Libs/AceLocale-3.0/AceLocale-3.0.lua new file mode 100644 index 0000000..d69aa73 --- /dev/null +++ b/Libs/AceLocale-3.0/AceLocale-3.0.lua @@ -0,0 +1,133 @@ +--- **AceLocale-3.0** manages localization in addons, allowing for multiple locale to be registered with fallback to the base locale for untranslated strings. +-- @class file +-- @name AceLocale-3.0 +-- @release $Id: AceLocale-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ +local MAJOR,MINOR = "AceLocale-3.0", 6 + +local AceLocale, oldminor = LibStub:NewLibrary(MAJOR, MINOR) + +if not AceLocale then return end -- no upgrade needed + +-- Lua APIs +local assert, tostring, error = assert, tostring, error +local getmetatable, setmetatable, rawset, rawget = getmetatable, setmetatable, rawset, rawget + +local gameLocale = GetLocale() +if gameLocale == "enGB" then + gameLocale = "enUS" +end + +AceLocale.apps = AceLocale.apps or {} -- array of ["AppName"]=localetableref +AceLocale.appnames = AceLocale.appnames or {} -- array of [localetableref]="AppName" + +-- This metatable is used on all tables returned from GetLocale +local readmeta = { + __index = function(self, key) -- requesting totally unknown entries: fire off a nonbreaking error and return key + rawset(self, key, key) -- only need to see the warning once, really + geterrorhandler()(MAJOR..": "..tostring(AceLocale.appnames[self])..": Missing entry for '"..tostring(key).."'") + return key + end +} + +-- This metatable is used on all tables returned from GetLocale if the silent flag is true, it does not issue a warning on unknown keys +local readmetasilent = { + __index = function(self, key) -- requesting totally unknown entries: return key + rawset(self, key, key) -- only need to invoke this function once + return key + end +} + +-- Remember the locale table being registered right now (it gets set by :NewLocale()) +-- NOTE: Do never try to register 2 locale tables at once and mix their definition. +local registering + +-- local assert false function +local assertfalse = function() assert(false) end + +-- This metatable proxy is used when registering nondefault locales +local writeproxy = setmetatable({}, { + __newindex = function(self, key, value) + rawset(registering, key, value == true and key or value) -- assigning values: replace 'true' with key string + end, + __index = assertfalse +}) + +-- This metatable proxy is used when registering the default locale. +-- It refuses to overwrite existing values +-- Reason 1: Allows loading locales in any order +-- Reason 2: If 2 modules have the same string, but only the first one to be +-- loaded has a translation for the current locale, the translation +-- doesn't get overwritten. +-- +local writedefaultproxy = setmetatable({}, { + __newindex = function(self, key, value) + if not rawget(registering, key) then + rawset(registering, key, value == true and key or value) + end + end, + __index = assertfalse +}) + +--- Register a new locale (or extend an existing one) for the specified application. +-- :NewLocale will return a table you can fill your locale into, or nil if the locale isn't needed for the players +-- game locale. +-- @paramsig application, locale[, isDefault[, silent]] +-- @param application Unique name of addon / module +-- @param locale Name of the locale to register, e.g. "enUS", "deDE", etc. +-- @param isDefault If this is the default locale being registered (your addon is written in this language, generally enUS) +-- @param silent If true, the locale will not issue warnings for missing keys. Must be set on the first locale registered. If set to "raw", nils will be returned for unknown keys (no metatable used). +-- @usage +-- -- enUS.lua +-- local L = LibStub("AceLocale-3.0"):NewLocale("TestLocale", "enUS", true) +-- L["string1"] = true +-- +-- -- deDE.lua +-- local L = LibStub("AceLocale-3.0"):NewLocale("TestLocale", "deDE") +-- if not L then return end +-- L["string1"] = "Zeichenkette1" +-- @return Locale Table to add localizations to, or nil if the current locale is not required. +function AceLocale:NewLocale(application, locale, isDefault, silent) + + -- GAME_LOCALE allows translators to test translations of addons without having that wow client installed + local activeGameLocale = GAME_LOCALE or gameLocale + + local app = AceLocale.apps[application] + + if silent and app and getmetatable(app) ~= readmetasilent then + geterrorhandler()("Usage: NewLocale(application, locale[, isDefault[, silent]]): 'silent' must be specified for the first locale registered") + end + + if not app then + if silent=="raw" then + app = {} + else + app = setmetatable({}, silent and readmetasilent or readmeta) + end + AceLocale.apps[application] = app + AceLocale.appnames[app] = application + end + + if locale ~= activeGameLocale and not isDefault then + return -- nop, we don't need these translations + end + + registering = app -- remember globally for writeproxy and writedefaultproxy + + if isDefault then + return writedefaultproxy + end + + return writeproxy +end + +--- Returns localizations for the current locale (or default locale if translations are missing). +-- Errors if nothing is registered (spank developer, not just a missing translation) +-- @param application Unique name of addon / module +-- @param silent If true, the locale is optional, silently return nil if it's not found (defaults to false, optional) +-- @return The locale table for the current language. +function AceLocale:GetLocale(application, silent) + if not silent and not AceLocale.apps[application] then + error("Usage: GetLocale(application[, silent]): 'application' - No locales registered for '"..tostring(application).."'", 2) + end + return AceLocale.apps[application] +end diff --git a/Libs/AceLocale-3.0/AceLocale-3.0.xml b/Libs/AceLocale-3.0/AceLocale-3.0.xml new file mode 100644 index 0000000..bf023f0 --- /dev/null +++ b/Libs/AceLocale-3.0/AceLocale-3.0.xml @@ -0,0 +1,4 @@ + +