Module:SoulUnlock: Difference between revisionsGive feedback
m working version of accumulate() |
m localization support |
||
| Line 2: | Line 2: | ||
local util_module = require('Module:Utilities') | local util_module = require('Module:Utilities') | ||
local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json") | local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json") | ||
local localization_map = { | |||
["RequiredGold"] = "Citadel_Hero_Stats_Souls", | |||
["AbilityUnlocks"] = "Citadel_Player_Level_AbilityUnlock", | |||
["AbilityPoints"] = "guide_upgrades_killing_guardians_header", | |||
["PowerIncrease"] = "Citadel_Player_Level_PowerIncreases" | |||
} | |||
local lang_module = require('Module:Lang') | |||
-- Accumulate the data from a list of entries of unlocks, AP, and PI's, to a hash with the # of each | -- Accumulate the data from a list of entries of unlocks, AP, and PI's, to a hash with the # of each | ||
| Line 44: | Line 51: | ||
local accumulated_data = accumulate() | local accumulated_data = accumulate() | ||
function p.localize(soul_unlock_key) | |||
localization_key = localization_map[soul_unlock_key] | |||
if localization_key == nil then | |||
return string.format("soul_unlock_key %s not in localization_map", soul_unlock_key) | |||
end | |||
-- Localize, nil for lang override, english string for fallback | |||
return lang_module.get_string(localization_key, nil, 'en') | |||
end | |||
function p.write_accumulated(frame) | function p.write_accumulated(frame) | ||
| Line 50: | Line 67: | ||
ret = ret .. "Index" .. i .. ": " | ret = ret .. "Index" .. i .. ": " | ||
for key, value in pairs(data) do | for key, value in pairs(data) do | ||
ret = ret .. string.format(" %s:%s", key, value) | ret = ret .. string.format(" %s:%s, ", p.localize(key), value) | ||
end | end | ||
ret = ret .. '<br>' | ret = ret .. '<br>' | ||