From fcdbb93c5ca730a71d9186f591a938c75ca28446 Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Mon, 14 Jun 2010 16:54:47 -0500 Subject: [PATCH] Localized Upgrade.lua --- Locales/enUS/base.lua | 14 ++++++++++++++ Upgrade.lua | 24 ++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Locales/enUS/base.lua b/Locales/enUS/base.lua index 3a9f76c..c57a1de 100644 --- a/Locales/enUS/base.lua +++ b/Locales/enUS/base.lua @@ -123,3 +123,17 @@ L["WT_RESTORE_DEFAULTS_CONFIRM"] = "Are you sure you want to restore default wei L["Okay"] = "Okay" L["WT_EXISTS"] = "The %s weight named \"%s\" already exists. Pick a different name." L["CLASS_WEIGHT_HEADER_FORMAT"] = "%s - %s" + +-- Upgrade.lua +L["UPGRADE_ERR_INV_DATA_TYPE"] = "WeightsWatcher: error: invalid data type \"%s\" passed to Upgrade()." +L["upgrade"] = "upgrade" +L["downgrade"] = "downgrade" +L["UPGRADE_ERR_NO_FUNC_TBL"] = "WeightsWatcher: error: no %s function table found." +L["LOADING_DEFAULTS"] = "WeightsWatcher: no %s data found, loading defaults." +L["account"] = "account" +L["character"] = "character" +L["UPGRADE_ATTEMPT"] = "WeightsWatcher: attempting to %s %s data from version %d%s%d to %d%s%d." +L["UPGRADE_ERR_NO_PATH"] = "WeightsWatcher: error: No %s data %s path found." +L["UPGRADE_ERR_GENERIC"] = "WeightsWatcher: %s data %s error." +L["UPGRADE_ERR_INF_LOOP"] = "WeightsWatcher: error: infinite loop in %s data %s." +L["UPGRADE_SUCCESS"] = "WeightsWatcher: %s data %s successful." diff --git a/Upgrade.lua b/Upgrade.lua index 2a75965..e2c464b 100644 --- a/Upgrade.lua +++ b/Upgrade.lua @@ -1,3 +1,5 @@ +local L = ww_localization + -- TODO: move this to a util(s).lua? function ww_deepTableCopy(object) local lookup_table = {} @@ -1077,10 +1079,12 @@ function WeightsWatcher.Upgrade(dataType) funcTable = upgradeCharFunctions downgradeFunctions = downgradeCharFunctions else - print("WeightsWatcher: error: invalid data type \"" .. dataType .. "\" passed to Upgrade().") + print(string.format(L["UPGRADE_ERR_INV_DATA_TYPE"], dataType)) return nil end + dataType = L[dataType] + if vars then oldMinorVersion = vars.dataMinorVersion oldMajorVersion = vars.dataMajorVersion @@ -1097,36 +1101,36 @@ function WeightsWatcher.Upgrade(dataType) end if newMajorVersion > oldMajorVersion or (newMajorVersion == oldMajorVersion and newMinorVersion > oldMinorVersion) then - direction = "up" + direction = L["upgrade"] else - direction = "down" + direction = L["downgrade"] funcTable = stringsToFuncs(vars.downgradeFunctions) end if funcTable == nil then - print("WeightsWatcher: error: no " .. direction .. "grade function table found.") + print(string.format(L["UPGRADE_ERR_NO_FUNC_TBL"], direction)) return nil end if oldMajorVersion == 0 and oldMinorVersion == 0 then - print("WeightsWatcher: no " .. dataType .. " data found, loading defaults.") + print(string.format(L["LOADING_DEFAULTS"], dataType)) else - print("WeightsWatcher: attempting to " .. direction .. "grade " .. dataType .. " data from version " .. oldMajorVersion .. "." .. oldMinorVersion .. " to " .. newMajorVersion .. "." .. newMinorVersion .. ".") + print(string.format(L["UPGRADE_ATTEMPT"], direction, dataType, oldMajorVersion, L["DECIMAL_SEPARATOR"], oldMinorVersion, newMajorVersion, L["DECIMAL_SEPARATOR"], newMinorVersion)) end local newVars = ww_deepTableCopy(vars) while oldMajorVersion ~= newMajorVersion or oldMinorVersion ~= newMinorVersion do if not funcTable[oldMajorVersion] or not funcTable[oldMajorVersion][oldMinorVersion] then - print("WeightsWatcher: error: No " .. dataType .. " data " .. direction .. "grade path found.") + print(string.format(L["UPGRADE_ERR_NO_PATH"], dataType, direction)) return nil end newVars = funcTable[oldMajorVersion][oldMinorVersion](newVars) if not newVars or not newVars.dataMinorVersion then - print("WeightsWatcher: " .. dataType .. " data " .. direction .. "grade error.") + print(string.format(L["UPGRADE_ERR_GENERIC"], dataType, direction)) return nil elseif oldMinorVersion == newVars.dataMinorVersion and oldMajorVersion == newVars.dataMajorVersion then - print("WeightsWatcher: error: infinite loop in " .. dataType .. " data " .. direction .. "grade.") + print(string.format(L["UPGRADE_ERR_INF_LOOP"], dataType, direction)) return nil end oldMinorVersion = newVars.dataMinorVersion @@ -1139,7 +1143,7 @@ function WeightsWatcher.Upgrade(dataType) newVars.downgradeFunctions = downgradeFunctions - print("WeightsWatcher: successfully " .. direction .. "graded " .. dataType .. " data.") + print(string.format(L["UPGRADE_SUCCESS"], dataType, direction)) return newVars end -- 1.7.9.5