From 01d1b93123da5eb8287e7e3706c6f0f1e0c073c0 Mon Sep 17 00:00:00 2001 From: MassCraxx Date: Wed, 25 Jan 2023 23:50:01 +0100 Subject: [PATCH 1/4] use predefined english spec names instead of localized ones, adjust invite message --- RaidBrowser/stats.lua | 67 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/RaidBrowser/stats.lua b/RaidBrowser/stats.lua index 728193b..d70cc67 100644 --- a/RaidBrowser/stats.lua +++ b/RaidBrowser/stats.lua @@ -39,6 +39,58 @@ local raid_achievements = { }, }; +local full_spec_names = { + -- Warrior + WarriorArms = "Arms Warrior", + WarriorFury = "Fury Warrior", + WarriorProtection = "Protection Warrior", + + -- Paladin + PaladinHoly = "Holy Paladin", + PaladinProtection = "Protection Paladin", + PaladinCombat = "Retribution Paladin", + + -- Hunter + HunterBeastMastery = "Beastmaster Hunter", + HunterMarksmanshop = "Marksman Hunter", + HunterSurvival = "Survival Hunter", + + -- Rogue + RogueAssassination = "Assassination Rogue", + RogueCombat = "Combat Rogue", + RogueSubtlety = "Subtlety Rogue", + + -- Priest + PriestDiscipline = "Discipline Priest", + PriestHoly = "Holy Priest", + PriestShadow = "Shadow Priest", + + -- DK + DeathKnightBlood = "Blood DK", + DeathKnightFrost = "Frost DK", + DeathKnightUnholy = "Unholy DK", + + -- Shaman + ShamanElementalCombat = "Elemental Shaman", + ShamanEnhancement = "Enhancement Shaman", + ShamanRestoration = "Restoration Shaman", + + -- Mage + MageArcane = "Arcane Mage", + MageFire = "Fire Mage", + MageFrost = "Frost Mage", + + -- Warlock + WarlockCurses = "Affliction Warlock", + WarlockSummoning = "Demo Warlock", + WarlockDestruction = "Destruction Warlock", + + -- Druid + DruidBalance = "Balance Druid", + DruidFeralCombat = "Feral Druid", + DruidRestoration = "Restroration Druid" +} + local function find_best_achievement(raid) local ids = raid_achievements[raid]; if not ids then @@ -86,20 +138,20 @@ end function raid_browser.stats.active_spec() local active_tab = raid_browser.stats.active_spec_index() - local tab_name = GetTalentTabInfo(active_tab); + local localized_tab_name, path, points, spec_name = GetTalentTabInfo(active_tab); -- If we're a feral druid, then we need to distinguish between tank and cat feral. - if tab_name == 'Feral Combat' then + if spec_name == 'DruidFeralCombat' then local protector_of_pack_talent = 22; local _, _, _, _, points = GetTalentInfo(active_tab, protector_of_pack_talent) if points > 0 then - return 'Feral (Bear)' + return 'Feral Druid (Bear)' else - return 'Feral (Cat)' + return 'Feral Druid (Cat)' end end - return tab_name; + return full_spec_names[spec_name] or spec_name; end function raid_browser.stats.raid_lock_info(instance_name, size) @@ -163,7 +215,10 @@ function raid_browser.stats.build_inv_string(raid_name) local class = UnitClass("player"); local spec, gs = raid_browser.stats.current_raidset(); - message = message .. gs .. 'gs ' .. spec .. ' ' .. class; + + --message = message .. gs .. 'gs ' .. spec .. ' ' .. class; + message = "LFG " .. raid_name .. " - " .. gs .. 'gs ' .. spec; + -- Remove difficulty and raid_name size from the string raid_name = string.gsub(raid_name, '[1|2][0|5](%w+)', ''); From 8e4c8ebad34b0fbbd49f1c48db090efd4e8dc46b Mon Sep 17 00:00:00 2001 From: MassCraxx Date: Sat, 28 Jan 2023 16:35:44 +0100 Subject: [PATCH 2/4] add and use localized_names in raid_list to fix saved display on non-engllish clients --- RaidBrowser/core.lua | 111 ++++++++++++++++++++++++++++++++++++++++++ RaidBrowser/gui.lua | 5 +- RaidBrowser/stats.lua | 15 ++++-- 3 files changed, 124 insertions(+), 7 deletions(-) diff --git a/RaidBrowser/core.lua b/RaidBrowser/core.lua index 09b5d60..a501282 100644 --- a/RaidBrowser/core.lua +++ b/RaidBrowser/core.lua @@ -98,6 +98,9 @@ local raid_list = { { name = 'icc25rep', instance_name = 'Icecrown Citadel', + localized_names = { + deDE = 'Eiskronenzitadelle' + }, size = 25, patterns = { 'icc'..csep..'25'..csep..'m?a?n?'..csep..'repu?t?a?t?i?o?n?'..csep..'', @@ -110,6 +113,9 @@ local raid_list = { { name = 'icc10rep', instance_name = 'Icecrown Citadel', + localized_names = { + deDE = 'Eiskronenzitadelle' + }, size = 10, patterns = { 'icc' .. csep .. '10' .. csep .. 'm?a?n?' .. csep .. 'repu?t?a?t?i?o?n?' .. csep, @@ -125,6 +131,9 @@ local raid_list = { { name = 'icc10hc', instance_name = 'Icecrown Citadel', + localized_names = { + deDE = 'Eiskronenzitadelle' + }, size = 10, patterns = std.algorithm.copy_back( create_pattern_from_template('icc', 10, 'hc'), @@ -135,6 +144,9 @@ local raid_list = { { name = 'icc25hc', instance_name = 'Icecrown Citadel', + localized_names = { + deDE = 'Eiskronenzitadelle' + }, size = 25, patterns = std.algorithm.copy_back( create_pattern_from_template('icc', 25, 'hc'), @@ -145,6 +157,9 @@ local raid_list = { { name = 'icc10nm', instance_name = 'Icecrown Citadel', + localized_names = { + deDE = 'Eiskronenzitadelle' + }, size = 10, patterns = create_pattern_from_template('icc', 10, 'nm'), }, @@ -152,6 +167,9 @@ local raid_list = { { name = 'icc25nm', instance_name = 'Icecrown Citadel', + localized_names = { + deDE = 'Eiskronenzitadelle' + }, size = 25, patterns = create_pattern_from_template('icc', 25, 'nm'), }, @@ -159,6 +177,9 @@ local raid_list = { { name = 'toc10hc', instance_name = 'Trial of the Crusader', + localized_names = { + deDE = 'Prüfung des Kreuzfahrers' + }, size = 10, patterns = std.algorithm.copy_back( create_pattern_from_template('toc', 10, 'hc'), @@ -172,6 +193,9 @@ local raid_list = { { name = 'toc25hc', instance_name = 'Trial of the Crusader', + localized_names = { + deDE = 'Prüfung des Kreuzfahrers' + }, size = 25, patterns = std.algorithm.copy_back( create_pattern_from_template('toc', 25, 'hc'), @@ -185,6 +209,9 @@ local raid_list = { { name = 'toc10nm', instance_name = 'Trial of the Crusader', + localized_names = { + deDE = 'Prüfung des Kreuzfahrers' + }, size = 10, patterns = std.algorithm.copy_back( create_pattern_from_template('toc', 10, 'nm'), @@ -195,6 +222,9 @@ local raid_list = { { name = 'toc25nm', instance_name = 'Trial of the Crusader', + localized_names = { + deDE = 'Prüfung des Kreuzfahrers' + }, size = 25, patterns = std.algorithm.copy_back( create_pattern_from_template('toc', 25, 'nm'), @@ -205,6 +235,9 @@ local raid_list = { { name = 'rs10hc', instance_name = 'The Ruby Sanctum', + localized_names = { + deDE = 'Das Rubinsanktum' + }, size = 10, patterns = create_pattern_from_template('rs', 10, 'hc') }, @@ -212,6 +245,9 @@ local raid_list = { { name = 'rs25hc', instance_name = 'The Ruby Sanctum', + localized_names = { + deDE = 'Das Rubinsanktum' + }, size = 25, patterns = std.algorithm.copy_back( create_pattern_from_template('rs', 25, 'hc'), @@ -224,6 +260,9 @@ local raid_list = { { name = 'rs10nm', instance_name = 'The Ruby Sanctum', + localized_names = { + deDE = 'Das Rubinsanktum' + }, size = 10, patterns = std.algorithm.copy_back( create_pattern_from_template('rs', 10, 'nm'), @@ -236,6 +275,9 @@ local raid_list = { { name = 'rs25nm', instance_name = 'The Ruby Sanctum', + localized_names = { + deDE = 'Das Rubinsanktum' + }, size = 25, patterns = std.algorithm.copy_back( { ' rs 25n ' }, @@ -246,6 +288,9 @@ local raid_list = { { name = 'voa10', instance_name = 'Vault of Archavon', + localized_names = { + deDE = 'Archavons Kammer' + }, size = 10, patterns = create_pattern_from_template('voa', 10, 'simple') }, @@ -253,6 +298,9 @@ local raid_list = { { name = 'voa25', instance_name = 'Vault of Archavon', + localized_names = { + deDE = 'Archavons Kammer' + }, size = 25, patterns = create_pattern_from_template('voa', 25, 'simple'), }, @@ -260,6 +308,8 @@ local raid_list = { { name = 'ulduar10', instance_name = 'Ulduar', + localized_names = { + }, size = 10, patterns = { 'ull?a?d[au]?[au]?r?'..csep..'10', @@ -269,6 +319,8 @@ local raid_list = { { name = 'ulduar25', instance_name = 'Ulduar', + localized_names = { + }, size = 25, patterns = { 'ull?a?d[au]?[au]?r?'..csep..'25', @@ -278,6 +330,9 @@ local raid_list = { { name = 'os10', instance_name = 'The Obsidian Sanctum', + localized_names = { + deDE = 'Das Obsidiansanktum' + }, size = 10, patterns = std.algorithm.copy_back( create_pattern_from_template('os', 10, 'simple'), @@ -288,6 +343,9 @@ local raid_list = { { name = 'os25', instance_name = 'The Obsidian Sanctum', + localized_names = { + deDE = 'Das Obsidiansanktum' + }, size = 25, patterns = std.algorithm.copy_back( create_pattern_from_template('os', 25, 'simple'), @@ -301,6 +359,8 @@ local raid_list = { { name = 'naxx10', instance_name = 'Naxxramas', + localized_names = { + }, size = 10, patterns = { 'the fall of naxxramas %(10 player%)', @@ -318,6 +378,8 @@ local raid_list = { { name = 'naxx25', instance_name = 'Naxxramas', + localized_names = { + }, size = 25, patterns = { 'the fall of naxxramas %(25 player%)', @@ -329,6 +391,9 @@ local raid_list = { { name = 'eoe10', instance_name = 'The Eye of Eternity', + localized_names = { + deDE = 'Das Auge der Ewigkeit' + }, size = 10, patterns = std.algorithm.copy_back( create_pattern_from_template('eoe', 10, 'simple'), @@ -342,6 +407,9 @@ local raid_list = { { name = 'eoe25', instance_name = 'The Eye of Eternity', + localized_names = { + deDE = 'Das Auge der Ewigkeit' + }, size = 25, patterns = std.algorithm.copy_back( create_pattern_from_template('eoe', 25, 'simple'), @@ -354,6 +422,9 @@ local raid_list = { { name = 'onyxia25', instance_name = 'Onyxia\'s Lair', + localized_names = { + deDE = 'Onyxias Hort' + }, size = 25, patterns = { "onyxia's lair (25 player)", @@ -364,6 +435,9 @@ local raid_list = { { name = 'onyxia10', instance_name = 'Onyxia\'s Lair', + localized_names = { + deDE = 'Onyxias Hort' + }, size = 10, patterns = { "onyxia's lair (10 player)", @@ -374,6 +448,9 @@ local raid_list = { { name = 'hyjal25', instace_name = 'The Battle For Mount Hyjal', + localized_names = { + deDE = 'Die Schlacht um den Berg Hyjal' + }, size = 25, patterns = { 'mount' .. csep .. 'hyjal', @@ -384,6 +461,8 @@ local raid_list = { { name = 'zul\'aman10', instance_name = 'Zul\'Aman', + localized_names = { + }, size = 10, patterns = { 'zul' .. csep .. '\'?' .. csep .. 'aman', @@ -393,6 +472,9 @@ local raid_list = { { name = 'tempest keep25', instance_name = 'Tempest Keep', + localized_names = { + deDE = "Festung der Stürme" + }, size = 25, patterns = { 'te*mpe*st' .. csep .. 'ke+p', @@ -404,6 +486,8 @@ local raid_list = { { name = 'karazhan10', instance_name = 'Karazhan', + localized_names = { + }, size = 10, patterns = { 'karaz?h?a?n?'..csep..'1?0?', -- karazhan @@ -415,6 +499,9 @@ local raid_list = { { name = 'mag\'s lair25', instance_name = 'Magtheridon\'s Lair', + localized_names = { + deDE = "Magtheridons Kammer" + }, size = 25, patterns = { 'magt?h?e?r?i?d?o?n?\'*s*' .. csep .. 'lai?r', @@ -424,6 +511,9 @@ local raid_list = { { name = 'gruul\'s lair25', instance_name = 'Gruul\'s Lair', + localized_names = { + deDE = "Gruuls Unterschlupf" + }, size = 25, patterns = { 'gruul\'*s*' .. csep .. 'l?a?i?r?', @@ -433,6 +523,9 @@ local raid_list = { { name = 'bwl40', instance_name = 'Blackwing Lair', + localized_names = { + deDE = "Pechschwingenhort" + }, size = 40, patterns = { 'gruul\'*s*' .. csep .. 'l?a?i?r?', @@ -442,6 +535,9 @@ local raid_list = { { name = 'molten core40', instance_name = 'Molten Core', + localized_names = { + deDE = "Geschmolzener Kern" + }, size = 40, patterns = { 'molte?n'..csep..'core?', @@ -452,6 +548,9 @@ local raid_list = { { name = 'black temple25', instance_name = 'Black Temple', + localized_names = { + deDE = "Der Schwarze Tempel" + }, size = 25, patterns = { 'black'..csep..'temple', @@ -462,6 +561,9 @@ local raid_list = { { name = 'sunwell25', instance_name = 'The Sunwell', + localized_names = { + deDE = "Der Sonnenbrunnen" + }, size = 25, patterns = { 'sunwell'..csep..'plateau', @@ -473,6 +575,9 @@ local raid_list = { { name = 'ssc25', instance_name = 'Coilfang: Serpentshrine Cavern', + localized_names = { + deDE = "Echsenkessel: Höhle des Schlangenschreins" + }, size = 25, patterns = { '^ssc', @@ -486,6 +591,9 @@ local raid_list = { { name = 'aq40', instance_name = 'Ahn\'Qiraj Temple', + localized_names = { + deDE = "Tempel von Ahn'Qiraj" + }, size = 40, patterns = { 'temple?'..csep..'of?'..csep..'ahn\'?'..csep..'qiraj', @@ -496,6 +604,9 @@ local raid_list = { { name = 'aq20', instance_name = "Ruins of Ahn'Qiraj", + localized_names = { + deDE = "Ruinen von Ahn'Qiraj" + }, size = 20, patterns = { 'ruins?'..csep..'of?'..csep..'ahn\'?'..csep..'qiraj', diff --git a/RaidBrowser/gui.lua b/RaidBrowser/gui.lua index 03d6a3f..fe1a84d 100644 --- a/RaidBrowser/gui.lua +++ b/RaidBrowser/gui.lua @@ -102,7 +102,7 @@ local function assign_lfr_button(button, host_name, lfm_info, index) -- Raid name button.class:SetText(button.raid_info.name); - button.raid_locked = raid_browser.stats.raid_lock_info(button.raid_info.instance_name, button.raid_info.size); + button.raid_locked, button.raid_reset_time = raid_browser.stats.raid_lock_info(button.raid_info); button.type = "party"; button.partyIcon:Show(); @@ -154,8 +154,7 @@ local function assign_lfr_button(button, host_name, lfm_info, index) if button.raid_locked then GameTooltip:AddLine('\nYou are |cffff0000saved|cffffd100 for ' .. button.raid_info.name); - local _, reset_time = raid_browser.stats.raid_lock_info(button.raid_info.instance_name, button.raid_info.size) - GameTooltip:AddLine('Lockout expires in ' .. format_seconds(reset_time)); + GameTooltip:AddLine('Lockout expires in ' .. format_seconds(button.raid_reset_time)); else GameTooltip:AddLine('\nYou are |cff00ffffnot saved|cffffd100 for ' .. button.raid_info.name); end diff --git a/RaidBrowser/stats.lua b/RaidBrowser/stats.lua index d70cc67..5956e1d 100644 --- a/RaidBrowser/stats.lua +++ b/RaidBrowser/stats.lua @@ -91,6 +91,8 @@ local full_spec_names = { DruidRestoration = "Restroration Druid" } +local locale = GetLocale() + local function find_best_achievement(raid) local ids = raid_achievements[raid]; if not ids then @@ -154,13 +156,18 @@ function raid_browser.stats.active_spec() return full_spec_names[spec_name] or spec_name; end -function raid_browser.stats.raid_lock_info(instance_name, size) - if instance_name == nil or size == nil then return false, nil end +function raid_browser.stats.raid_lock_info(raid_info) + local instance_name = raid_info.instace_name + if raid_info.localized_names and raid_info.localized_names[locale] then + instance_name = raid_info.localized_names[locale] + end + + if instance_name == nil or raid_info.size == nil then return false, nil end for i = 1, GetNumSavedInstances() do - local saved_name, _, reset, _, locked, _, _, _, saved_size = GetSavedInstanceInfo(i); + local saved_name, id, reset, difficulty, locked, _, _, _, saved_size = GetSavedInstanceInfo(i); if saved_name ~= nil then -- @napnapnap lockout fix (c8207076730d04f41b881dea3dd9f6ca32655372) - if string.lower(saved_name) == string.lower(instance_name) and saved_size == size and locked then + if string.lower(saved_name) == string.lower(instance_name) and saved_size == raid_info.size and locked then return true, reset; end end From 43a026039021dc1e01a640d2d184366c1c6bdf86 Mon Sep 17 00:00:00 2001 From: MassCraxx Date: Sat, 28 Jan 2023 17:31:40 +0100 Subject: [PATCH 3/4] integrate LibBabble to deal with Raid name translations --- .../Libs/LibBabble-3.0/LibBabble-3.0.lua | 292 ++ .../Libs/LibBabble-3.0/LibBabble-3.0.xml | 5 + .../Libs/LibBabble-3.0/LibBabble-Zone-3.0.lua | 2554 +++++++++++++++++ .../Libs/LibBabble-3.0/LibBabble-Zone-3.0.toc | 18 + RaidBrowser/core.lua | 111 - RaidBrowser/stats.lua | 13 +- 6 files changed, 2877 insertions(+), 116 deletions(-) create mode 100644 RaidBrowser/Libs/LibBabble-3.0/LibBabble-3.0.lua create mode 100644 RaidBrowser/Libs/LibBabble-3.0/LibBabble-3.0.xml create mode 100644 RaidBrowser/Libs/LibBabble-3.0/LibBabble-Zone-3.0.lua create mode 100644 RaidBrowser/Libs/LibBabble-3.0/LibBabble-Zone-3.0.toc diff --git a/RaidBrowser/Libs/LibBabble-3.0/LibBabble-3.0.lua b/RaidBrowser/Libs/LibBabble-3.0/LibBabble-3.0.lua new file mode 100644 index 0000000..fc4a012 --- /dev/null +++ b/RaidBrowser/Libs/LibBabble-3.0/LibBabble-3.0.lua @@ -0,0 +1,292 @@ +-- LibBabble-3.0 is hereby placed in the Public Domain +-- Credits: ckknight +local LIBBABBLE_MAJOR, LIBBABBLE_MINOR = "LibBabble-3.0", 2 + +local LibBabble = LibStub:NewLibrary(LIBBABBLE_MAJOR, LIBBABBLE_MINOR) +if not LibBabble then + return +end + +local data = LibBabble.data or {} +for k,v in pairs(LibBabble) do + LibBabble[k] = nil +end +LibBabble.data = data + +local tablesToDB = {} +for namespace, db in pairs(data) do + for k,v in pairs(db) do + tablesToDB[v] = db + end +end + +local function warn(message) + local _, ret = pcall(error, message, 3) + geterrorhandler()(ret) +end + +local lookup_mt = { __index = function(self, key) + local db = tablesToDB[self] + local current_key = db.current[key] + if current_key then + self[key] = current_key + return current_key + end + local base_key = db.base[key] + local real_MAJOR_VERSION + for k,v in pairs(data) do + if v == db then + real_MAJOR_VERSION = k + break + end + end + if not real_MAJOR_VERSION then + real_MAJOR_VERSION = LIBBABBLE_MAJOR + end + if base_key then + warn(("%s: Translation %q not found for locale %q"):format(real_MAJOR_VERSION, key, GetLocale())) + rawset(self, key, base_key) + return base_key + end + warn(("%s: Translation %q not found."):format(real_MAJOR_VERSION, key)) + rawset(self, key, key) + return key +end } + +local function initLookup(module, lookup) + local db = tablesToDB[module] + for k in pairs(lookup) do + lookup[k] = nil + end + setmetatable(lookup, lookup_mt) + tablesToDB[lookup] = db + db.lookup = lookup + return lookup +end + +local function initReverse(module, reverse) + local db = tablesToDB[module] + for k in pairs(reverse) do + reverse[k] = nil + end + for k,v in pairs(db.current) do + reverse[v] = k + end + tablesToDB[reverse] = db + db.reverse = reverse + db.reverseIterators = nil + return reverse +end + +local prototype = {} +local prototype_mt = {__index = prototype} + +--[[--------------------------------------------------------------------------- +Notes: + * If you try to access a nonexistent key, it will warn but allow the code to pass through. +Returns: + A lookup table for english to localized words. +Example: + local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want. + local BL = B:GetLookupTable() + assert(BL["Some english word"] == "Some localized word") + DoSomething(BL["Some english word that doesn't exist"]) -- warning! +-----------------------------------------------------------------------------]] +function prototype:GetLookupTable() + local db = tablesToDB[self] + + local lookup = db.lookup + if lookup then + return lookup + end + return initLookup(self, {}) +end +--[[--------------------------------------------------------------------------- +Notes: + * If you try to access a nonexistent key, it will return nil. +Returns: + A lookup table for english to localized words. +Example: + local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want. + local B_has = B:GetUnstrictLookupTable() + assert(B_has["Some english word"] == "Some localized word") + assert(B_has["Some english word that doesn't exist"] == nil) +-----------------------------------------------------------------------------]] +function prototype:GetUnstrictLookupTable() + local db = tablesToDB[self] + + return db.current +end +--[[--------------------------------------------------------------------------- +Notes: + * If you try to access a nonexistent key, it will return nil. + * This is useful for checking if the base (English) table has a key, even if the localized one does not have it registered. +Returns: + A lookup table for english to localized words. +Example: + local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want. + local B_hasBase = B:GetBaseLookupTable() + assert(B_hasBase["Some english word"] == "Some english word") + assert(B_hasBase["Some english word that doesn't exist"] == nil) +-----------------------------------------------------------------------------]] +function prototype:GetBaseLookupTable() + local db = tablesToDB[self] + + return db.base +end +--[[--------------------------------------------------------------------------- +Notes: + * If you try to access a nonexistent key, it will return nil. + * This will return only one English word that it maps to, if there are more than one to check, see :GetReverseIterator("word") +Returns: + A lookup table for localized to english words. +Example: + local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want. + local BR = B:GetReverseLookupTable() + assert(BR["Some localized word"] == "Some english word") + assert(BR["Some localized word that doesn't exist"] == nil) +-----------------------------------------------------------------------------]] +function prototype:GetReverseLookupTable() + local db = tablesToDB[self] + + local reverse = db.reverse + if reverse then + return reverse + end + return initReverse(self, {}) +end +local blank = {} +local weakVal = {__mode='v'} +--[[--------------------------------------------------------------------------- +Arguments: + string - the localized word to chek for. +Returns: + An iterator to traverse all English words that map to the given key +Example: + local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want. + for word in B:GetReverseIterator("Some localized word") do + DoSomething(word) + end +-----------------------------------------------------------------------------]] +function prototype:GetReverseIterator(key) + local db = tablesToDB[self] + local reverseIterators = db.reverseIterators + if not reverseIterators then + reverseIterators = setmetatable({}, weakVal) + db.reverseIterators = reverseIterators + elseif reverseIterators[key] then + return pairs(reverseIterators[key]) + end + local t + for k,v in pairs(db.current) do + if v == key then + if not t then + t = {} + end + t[k] = true + end + end + reverseIterators[key] = t or blank + return pairs(reverseIterators[key]) +end +--[[--------------------------------------------------------------------------- +Returns: + An iterator to traverse all translations English to localized. +Example: + local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want. + for english, localized in B:Iterate() do + DoSomething(english, localized) + end +-----------------------------------------------------------------------------]] +function prototype:Iterate() + local db = tablesToDB[self] + + return pairs(db.current) +end + +-- #NODOC +-- modules need to call this to set the base table +function prototype:SetBaseTranslations(base) + local db = tablesToDB[self] + local oldBase = db.base + if oldBase then + for k in pairs(oldBase) do + oldBase[k] = nil + end + for k, v in pairs(base) do + oldBase[k] = v + end + base = oldBase + else + db.base = base + end + for k,v in pairs(base) do + if v == true then + base[k] = k + end + end +end + +local function init(module) + local db = tablesToDB[module] + if db.lookup then + initLookup(module, db.lookup) + end + if db.reverse then + initReverse(module, db.reverse) + end + db.reverseIterators = nil +end + +-- #NODOC +-- modules need to call this to set the current table. if current is true, use the base table. +function prototype:SetCurrentTranslations(current) + local db = tablesToDB[self] + if current == true then + db.current = db.base + else + local oldCurrent = db.current + if oldCurrent then + for k in pairs(oldCurrent) do + oldCurrent[k] = nil + end + for k, v in pairs(current) do + oldCurrent[k] = v + end + current = oldCurrent + else + db.current = current + end + end + init(self) +end + +for namespace, db in pairs(data) do + setmetatable(db.module, prototype_mt) + init(db.module) +end + +-- #NODOC +-- modules need to call this to create a new namespace. +function LibBabble:New(namespace, minor) + local module, oldminor = LibStub:NewLibrary(namespace, minor) + if not module then + return + end + + if not oldminor then + local db = { + module = module, + } + data[namespace] = db + tablesToDB[module] = db + else + for k,v in pairs(module) do + module[k] = nil + end + end + + setmetatable(module, prototype_mt) + + return module +end diff --git a/RaidBrowser/Libs/LibBabble-3.0/LibBabble-3.0.xml b/RaidBrowser/Libs/LibBabble-3.0/LibBabble-3.0.xml new file mode 100644 index 0000000..a39f7a7 --- /dev/null +++ b/RaidBrowser/Libs/LibBabble-3.0/LibBabble-3.0.xml @@ -0,0 +1,5 @@ + +