diff --git a/DarkMode.toc b/DarkMode.toc index 97f347e..699d817 100644 --- a/DarkMode.toc +++ b/DarkMode.toc @@ -3,7 +3,7 @@ ## Interface-Wrath: 30403 ## Interface: 100200 -## Version: 0.4.11 +## Version: 0.4.12 ## Title: DarkMode by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR diff --git a/DarkMode_TBC.toc b/DarkMode_TBC.toc index 9b0e96e..05d7320 100644 --- a/DarkMode_TBC.toc +++ b/DarkMode_TBC.toc @@ -1,5 +1,5 @@ ## Interface: 20504 -## Version: 0.4.11 +## Version: 0.4.12 ## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR diff --git a/DarkMode_Vanilla.toc b/DarkMode_Vanilla.toc index 7bc4aa0..758333d 100644 --- a/DarkMode_Vanilla.toc +++ b/DarkMode_Vanilla.toc @@ -1,5 +1,5 @@ ## Interface: 11500 -## Version: 0.4.11 +## Version: 0.4.12 ## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR diff --git a/DarkMode_Wrath.toc b/DarkMode_Wrath.toc index 476e033..d04118e 100644 --- a/DarkMode_Wrath.toc +++ b/DarkMode_Wrath.toc @@ -1,5 +1,5 @@ ## Interface: 30403 -## Version: 0.4.11 +## Version: 0.4.12 ## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR diff --git a/libs/D4Lib/D4Translations.lua b/libs/D4Lib/D4Translations.lua index cfa4395..9f3482b 100644 --- a/libs/D4Lib/D4Translations.lua +++ b/libs/D4Lib/D4Translations.lua @@ -1,14 +1,30 @@ -function D4:Trans(key, value, lang) +function D4:Trans(key, lang, t1, t2, t3) D4.trans = D4.trans or {} if lang == nil then lang = GetLocale() end D4.trans[lang] = D4.trans[lang] or {} - if D4.trans[lang][key] ~= nil then return D4.trans[lang][key] end - if value ~= nil then return value end + local result = nil + if D4.trans[lang][key] ~= nil then + result = D4.trans[lang][key] + elseif D4.trans["enUS"][key] ~= nil then + result = D4.trans["enUS"][key] + end + + if t1 and t2 and t3 then + result = format(result, t1, t2, t3) + end + + if t1 and t2 then + result = format(result, t1, t2) + end + + if t1 then + result = format(result, t1) + end - return key + return result or key end function D4:AddTrans(lang, key, value) diff --git a/libs/D4Lib/D4Versions.lua b/libs/D4Lib/D4Versions.lua index 6e8abbb..de91e05 100644 --- a/libs/D4Lib/D4Versions.lua +++ b/libs/D4Lib/D4Versions.lua @@ -1,5 +1,5 @@ local AddonName, _ = ... -D4VersionTab = D4VersionTab or {} +D4.VersionTab = D4.VersionTab or {} local pre = "D4PREFIX" C_ChatInfo.RegisterAddonMessagePrefix(pre) function D4:SetVersion(name, icon, ver) @@ -21,20 +21,20 @@ function D4:SetVersion(name, icon, ver) return false end - if D4VersionTab[string.lower(name)] ~= nil then + if D4.VersionTab[string.lower(name)] ~= nil then D4:msg("|cffff0000VERSION ALREADY SET", name) return false end local index = string.lower(name) - D4VersionTab[index] = {} - D4VersionTab[index].name = name - D4VersionTab[index].version = ver - D4VersionTab[index].icon = icon - D4VersionTab[index].foundHigher = false + D4.VersionTab[index] = {} + D4.VersionTab[index].name = name + D4.VersionTab[index].version = ver + D4.VersionTab[index].icon = icon + D4.VersionTab[index].foundHigher = false local nameOrder = {} - for k, v in pairs(D4VersionTab) do + for k, v in pairs(D4.VersionTab) do tinsert(nameOrder, string.lower(k)) end @@ -42,7 +42,7 @@ function D4:SetVersion(name, icon, ver) local id = 0 for i, v in pairs(nameOrder) do id = id + 1 - D4VersionTab[string.lower(v)].id = id + D4.VersionTab[string.lower(v)].id = id end end @@ -53,7 +53,7 @@ function D4:GetVersion(name) return false end - if name and D4VersionTab[string.lower(name)] then return D4VersionTab[string.lower(name)].version end + if name and D4.VersionTab[string.lower(name)] then return D4.VersionTab[string.lower(name)].version end return nil end @@ -65,7 +65,7 @@ function D4:FoundHigher(name) return false end - if name and D4VersionTab[string.lower(name)] then return D4VersionTab[string.lower(name)].foundHigher end + if name and D4.VersionTab[string.lower(name)] then return D4.VersionTab[string.lower(name)].foundHigher end return false end @@ -94,9 +94,9 @@ function D4:CheckVersion(name, ver) local ov1, ov2, ov3 = string.split(".", ver) local cv1, cv2, cv3 = string.split(".", D4:GetVersion(name)) local higher = D4:IsHigherVersion(ov1, ov2, ov3, cv1, cv2, cv3) - if higher and name and D4VersionTab and D4VersionTab[string.lower(name)] then - D4VersionTab[string.lower(name)].foundHigher = true - D4:MSG(name, D4VersionTab[string.lower(name)].icon, format("New Version available (v%s -> v%s)", D4:GetVersion(name), ver)) + if higher and name and D4.VersionTab and D4.VersionTab[string.lower(name)] then + D4.VersionTab[string.lower(name)].foundHigher = true + D4:MSG(name, D4.VersionTab[string.lower(name)].icon, format("New Version available (v%s -> v%s)", D4:GetVersion(name), ver)) end end @@ -108,8 +108,8 @@ f:SetScript( C_Timer.After( 2, function() - if D4VersionTab[string.lower(AddonName)] then - local id = D4VersionTab[string.lower(AddonName)].id or 0 + if D4.VersionTab[string.lower(AddonName)] then + local id = D4.VersionTab[string.lower(AddonName)].id or 0 C_Timer.After( id * 0.1, function() diff --git a/settings.lua b/settings.lua index 27f6b43..139f6fd 100644 --- a/settings.lua +++ b/settings.lua @@ -222,8 +222,8 @@ function DarkMode:InitDMSettings() DMSettings:Hide() end - D4:SetVersion(AddonName, 136122, "0.4.11") - DMSettings.TitleText:SetText(format("DarkMode |T136122:16:16:0:0|t v|cff3FC7EB%s", "0.4.11")) + D4:SetVersion(AddonName, 136122, "0.4.12") + DMSettings.TitleText:SetText(format("DarkMode |T136122:16:16:0:0|t v|cff3FC7EB%s", "0.4.12")) DMSettings.CloseButton:SetScript( "OnClick", function()