add latest TBC version of !Compatibility and !DebugTools

This commit is contained in:
Pinya
2017-12-14 20:10:16 +03:00
parent c7007b9186
commit 0be2449e90
19 changed files with 4858 additions and 0 deletions
+292
View File
@@ -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
+239
View File
@@ -0,0 +1,239 @@
--[[
Name: LibBabble-Class-3.0
Revision: $Rev: 50 $
Author(s): ckknight (ckknight@gmail.com)
Website: http://ckknight.wowinterface.com/
Dependencies: None
License: MIT
]]
local MAJOR_VERSION = "LibBabble-Class-3.0"
local MINOR_VERSION = 90000 + tonumber(("$Revision: 50 $"):match("%d+"))
if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end
local lib = LibStub("LibBabble-3.0"):New(MAJOR_VERSION, MINOR_VERSION)
if not lib then return end
local GAME_LOCALE = GetLocale()
lib:SetBaseTranslations {
Warlock = true,
Warrior = true,
Hunter = true,
Mage = true,
Priest = true,
Druid = true,
Paladin = true,
Shaman = true,
Rogue = true,
Deathknight = "Death Knight",
WARLOCK = true,
WARRIOR = true,
HUNTER = true,
MAGE = true,
PRIEST = true,
DRUID = true,
PALADIN = true,
SHAMAN = true,
ROGUE = true,
DEATHKNIGHT = "Death Knight",
}
if GAME_LOCALE == "enUS" then
lib:SetCurrentTranslations(true)
elseif GAME_LOCALE == "deDE" then
lib:SetCurrentTranslations {
["Warlock"] = "Hexenmeister",
["Warrior"] = "Krieger",
["Hunter"] = "Jäger",
["Mage"] = "Magier",
["Priest"] = "Priester",
["Druid"] = "Druide",
["Paladin"] = "Paladin",
["Shaman"] = "Schamane",
["Rogue"] = "Schurke",
["Deathknight"] = "Todesritter",
["WARLOCK"] = "Hexenmeisterin",
["WARRIOR"] = "Kriegerin",
["HUNTER"] = "Jägerin",
["MAGE"] = "Magierin",
["PRIEST"] = "Priesterin",
["DRUID"] = "Druidin",
["PALADIN"] = "Paladin",
["SHAMAN"] = "Schamanin",
["ROGUE"] = "Schurkin",
["DEATHKNIGHT"] = "Todesritter",
}
elseif GAME_LOCALE == "frFR" then
lib:SetCurrentTranslations {
["Warlock"] = "Démoniste",
["Warrior"] = "Guerrier",
["Hunter"] = "Chasseur",
["Mage"] = "Mage",
["Priest"] = "Prêtre",
["Druid"] = "Druide",
["Paladin"] = "Paladin",
["Shaman"] = "Chaman",
["Rogue"] = "Voleur",
["Deathknight"] = "Chevalier de la mort",
["WARLOCK"] = "Démoniste",
["WARRIOR"] = "Guerrière",
["HUNTER"] = "Chasseresse",
["MAGE"] = "Mage",
["PRIEST"] = "Prêtresse",
["DRUID"] = "Druidesse",
["PALADIN"] = "Paladin",
["SHAMAN"] = "Chamane",
["ROGUE"] = "Voleuse",
["DEATHKNIGHT"] = "Chevalier de la mort",
}
elseif GAME_LOCALE == "zhCN" then
lib:SetCurrentTranslations {
["Warlock"] = "术士",
["Warrior"] = "战士",
["Hunter"] = "猎人",
["Mage"] = "法师",
["Priest"] = "牧师",
["Druid"] = "德鲁伊",
["Paladin"] = "圣骑士",
["Shaman"] = "萨满祭司",
["Rogue"] = "潜行者",
["Deathknight"] = "死亡骑士",
["WARLOCK"] = "术士",
["WARRIOR"] = "战士",
["HUNTER"] = "猎人",
["MAGE"] = "法师",
["PRIEST"] = "牧师",
["DRUID"] = "德鲁伊",
["PALADIN"] = "圣骑士",
["SHAMAN"] = "萨满祭司",
["ROGUE"] = "潜行者",
["DEATHKNIGHT"] = "死亡骑士",
}
elseif GAME_LOCALE == "zhTW" then
lib:SetCurrentTranslations {
["Warlock"] = "術士",
["Warrior"] = "戰士",
["Hunter"] = "獵人",
["Mage"] = "法師",
["Priest"] = "牧師",
["Druid"] = "德魯伊",
["Paladin"] = "聖騎士",
["Shaman"] = "薩滿",
["Rogue"] = "盜賊",
["Deathknight"] = "死亡騎士",
["WARLOCK"] = "術士",
["WARRIOR"] = "戰士",
["HUNTER"] = "獵人",
["MAGE"] = "法師",
["PRIEST"] = "牧師",
["DRUID"] = "德魯伊",
["PALADIN"] = "聖騎士",
["SHAMAN"] = "薩滿",
["ROGUE"] = "盜賊",
["DEATHKNIGHT"] = "死亡騎士",
}
elseif GAME_LOCALE == "koKR" then
lib:SetCurrentTranslations {
["Warlock"] = "흑마법사",
["Warrior"] = "전사",
["Hunter"] = "사냥꾼",
["Mage"] = "마법사",
["Priest"] = "사제",
["Druid"] = "드루이드",
["Paladin"] = "성기사",
["Shaman"] = "주술사",
["Rogue"] = "도적",
["Deathknight"] = "죽음의 기사",
["WARLOCK"] = "흑마법사",
["WARRIOR"] = "전사",
["HUNTER"] = "사냥꾼",
["MAGE"] = "마법사",
["PRIEST"] = "사제",
["DRUID"] = "드루이드",
["PALADIN"] = "성기사",
["SHAMAN"] = "주술사",
["ROGUE"] = "도적",
["DEATHKNIGHT"] = "죽음의 기사",
}
elseif GAME_LOCALE == "esES" then
lib:SetCurrentTranslations {
["Warlock"] = "Brujo",
["Warrior"] = "Guerrero",
["Hunter"] = "Cazador",
["Mage"] = "Mago",
["Priest"] = "Sacerdote",
["Druid"] = "Druida",
["Paladin"] = "Paladín",
["Shaman"] = "Chamán",
["Rogue"] = "Pícaro",
["Deathknight"] = "Caballero de la muerte",
["WARLOCK"] = "Bruja",
["WARRIOR"] = "Guerrera",
["HUNTER"] = "Cazadora",
["MAGE"] = "Maga",
["PRIEST"] = "Sacerdotisa",
["DRUID"] = "Druida",
["PALADIN"] = "Paladín",
["SHAMAN"] = "Chamán",
["ROGUE"] = "Pícara",
["Deathknight"] = "Caballero de la muerte",
}
elseif GAME_LOCALE == "esMX" then
lib:SetCurrentTranslations {
["Warlock"] = "Brujo",
["Warrior"] = "Guerrero",
["Hunter"] = "Cazador",
["Mage"] = "Mago",
["Priest"] = "Sacerdote",
["Druid"] = "Druida",
["Paladin"] = "Paladín",
["Shaman"] = "Chamán",
["Rogue"] = "Pícaro",
["Deathknight"] = "Caballero de la muerte",
["WARLOCK"] = "Bruja",
["WARRIOR"] = "Guerrera",
["HUNTER"] = "Cazadora",
["MAGE"] = "Maga",
["PRIEST"] = "Sacerdotisa",
["DRUID"] = "Druida",
["PALADIN"] = "Paladín",
["SHAMAN"] = "Chamán",
["ROGUE"] = "Pícara",
["Deathknight"] = "Caballero de la muerte",
}
elseif GAME_LOCALE == "ruRU" then
lib:SetCurrentTranslations {
["Warlock"] = "Чернокнижник",
["Warrior"] = "Воин",
["Hunter"] = "Охотник",
["Mage"] = "Маг",
["Priest"] = "Жрец",
["Druid"] = "Друид",
["Paladin"] = "Паладин",
["Shaman"] = "Шаман",
["Rogue"] = "Разбойник",
["Deathknight"] = "Рыцарь смерти",
["WARLOCK"] = "Чернокнижница",
["WARRIOR"] = "Воин",
["HUNTER"] = "Охотница",
["MAGE"] = "Маг",
["PRIEST"] = "Жрица",
["DRUID"] = "Друид",
["PALADIN"] = "Паладин",
["SHAMAN"] = "Шаманка",
["ROGUE"] = "Разбойница",
["DEATHKNIGHT"] = "Рыцарь смерти",
}
else
error(("%s: Locale %q not supported"):format(MAJOR_VERSION, GAME_LOCALE))
end
File diff suppressed because it is too large Load Diff
+51
View File
@@ -0,0 +1,51 @@
-- $Id: LibStub.lua 103 2014-10-16 03:02:50Z mikk $
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/addons/libstub/ for more info
-- LibStub is hereby placed in the Public Domain
-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
local LibStub = _G[LIBSTUB_MAJOR]
-- Check to see is this version of the stub is obsolete
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
LibStub = LibStub or {libs = {}, minors = {} }
_G[LIBSTUB_MAJOR] = LibStub
LibStub.minor = LIBSTUB_MINOR
-- LibStub:NewLibrary(major, minor)
-- major (string) - the major version of the library
-- minor (string or number ) - the minor version of the library
--
-- returns nil if a newer or same version of the lib is already present
-- returns empty library object or old library object if upgrade is needed
function LibStub:NewLibrary(major, minor)
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
local oldminor = self.minors[major]
if oldminor and oldminor >= minor then return nil end
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
return self.libs[major], oldminor
end
-- LibStub:GetLibrary(major, [silent])
-- major (string) - the major version of the library
-- silent (boolean) - if true, library is optional, silently return nil if its not found
--
-- throws an error if the library can not be found (except silent is set)
-- returns the library object if found
function LibStub:GetLibrary(major, silent)
if not self.libs[major] and not silent then
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
end
return self.libs[major], self.minors[major]
end
-- LibStub:IterateLibraries()
--
-- Returns an iterator for the currently registered libraries
function LibStub:IterateLibraries()
return pairs(self.libs)
end
setmetatable(LibStub, { __call = LibStub.GetLibrary })
end
+6
View File
@@ -0,0 +1,6 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="LibStub.lua"/>
<Script file="LibBabble-3.0.lua"/>
<Script file="LibBabble-Class-3.0.lua"/>
<Script file="LibBabble-Zone-3.0.lua"/>
</Ui>