Module:AbilityHints: Difference between revisionsGive feedback
m unstoppable "negative status effect" => "cc effect" |
Use Data:Dictionary keys for hint tooltips instead of hardcoded English (with help from vergir-bot LLM) |
||
| Line 2: | Line 2: | ||
-- Used by Template:AbilitySection. Styles are there too. | -- Used by Template:AbilitySection. Styles are there too. | ||
-- label_dict_key names the [[Data:Dictionary]] entry holding the tooltip text. It is | |||
-- resolved at render time rather than here, so the tooltip follows the page language | |||
-- and so no frame is needed while the module is still loading. | |||
local CONFIG = { | local CONFIG = { | ||
{ list = "melee", file = "Melee Lifesteal.png", | { list = "melee", file = "Melee Lifesteal.png", label_dict_key = "AbilityHintsMelee" }, | ||
{ list = "dontbreakstealth", file = "Veil Walker.png", | { list = "dontbreakstealth", file = "Veil Walker.png", label_dict_key = "AbilityHintsDontBreakStealth" }, | ||
{ list = "movementbased", file = "Slowing Hex.png", | { list = "movementbased", file = "Slowing Hex.png", label_dict_key = "AbilityHintsMovementBased" }, | ||
{ list = "debuffresist", file = "Debuff Reducer.png", | { list = "debuffresist", file = "Debuff Reducer.png", label_dict_key = "AbilityHintsDebuffResist" }, | ||
{ list = "heal", file = "Healing Booster.png", | { list = "heal", file = "Healing Booster.png", label_dict_key = "AbilityHintsHeal" }, | ||
{ list = "healingtempo", file = "Healing Tempo.png", | { list = "healingtempo", file = "Healing Tempo.png", label_dict_key = "AbilityHintsHealingTempo" }, | ||
{ list = "reactivebarrier", file = "Reactive Barrier.png", | { list = "reactivebarrier", file = "Reactive Barrier.png", label_dict_key = "AbilityHintsReactiveBarrier" }, | ||
{ list = "dispelmagic", file = "Dispel Magic.png", | { list = "dispelmagic", file = "Dispel Magic.png", label_dict_key = "AbilityHintsDispelMagic" }, | ||
{ list = "indomitable", file = "Indomitable.png", | { list = "indomitable", file = "Indomitable.png", label_dict_key = "AbilityHintsIndomitable" }, | ||
{ list = "unstoppable", file = "Unstoppable.png", | { list = "unstoppable", file = "Unstoppable.png", label_dict_key = "AbilityHintsUnstoppable" }, | ||
{ list = "platedarmor", file = "Plated Armor.png", | { list = "platedarmor", file = "Plated Armor.png", label_dict_key = "AbilityHintsPlatedArmor" }, | ||
{ list = "summons", file = "Monster Rounds.png", | { list = "summons", file = "Monster Rounds.png", label_dict_key = "AbilityHintsSummons" }, | ||
} | |||
-- Tooltip wording for a manually placed icon, keyed by its iconbox state. Each entry | |||
-- takes the item title as {{{1}}}, so translations can put the object where their | |||
-- grammar wants it rather than always after the verb. | |||
local STATE_DICT_KEYS = { | |||
normal = "AbilityHintsInteracts", | |||
disabled = "AbilityHintsInteractsNot", | |||
partial = "AbilityHintsInteractsPartial", | |||
} | } | ||
local AbilityTable = require("Module:AbilityTable") | local AbilityTable = require("Module:AbilityTable") | ||
local dictionary = require("Module:Dictionary") | |||
local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json") | local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json") | ||
local item_data = mw.loadJsonData("Data:ItemData.json") | local item_data = mw.loadJsonData("Data:ItemData.json") | ||
| Line 62: | Line 75: | ||
local function hint_icon(def) | local function hint_icon(def) | ||
return '<span class="ability-hint">' .. icon_img(def.file) | return '<span class="ability-hint">' .. icon_img(def.file) | ||
.. '<span class="ability-hint-tip">' .. def. | .. '<span class="ability-hint-tip">' .. dictionary.translate(def.label_dict_key) .. '</span></span>' | ||
end | end | ||
local function manual_icon(m) | local function manual_icon(m) | ||
local cls = 'ability-hint' | local cls = 'ability-hint' | ||
local | local dict_key = STATE_DICT_KEYS.normal | ||
local partial = false | local partial = false | ||
if m.state == 'disabled' then | if m.state == 'disabled' then | ||
cls = cls .. ' ability-hint--disabled' | cls = cls .. ' ability-hint--disabled' | ||
dict_key = STATE_DICT_KEYS.disabled | |||
elseif m.state == 'partial' then | elseif m.state == 'partial' then | ||
dict_key = STATE_DICT_KEYS.partial | |||
partial = true | partial = true | ||
end | end | ||
local tip = dictionary.translate(dict_key, nil, nil, { m.title }) | |||
.. '<br>' .. dictionary.translate('AbilityHintsClickReveal') | |||
return '<span class="' .. cls .. '">' .. icon_img(m.file, '#' .. m.anchor, partial) | return '<span class="' .. cls .. '">' .. icon_img(m.file, '#' .. m.anchor, partial) | ||
.. '<span class="ability-hint-tip">' .. | .. '<span class="ability-hint-tip">' .. tip .. '</span></span>' | ||
end | end | ||