Module:Lang: Difference between revisionsGive feedback
Gammaton32 (talk | contribs) No edit summary |
Added replacement of keybind tags with keybind strings |
||
| Line 88: | Line 88: | ||
-- Process panel tags | -- Process panel tags | ||
text = text:gsub('<Panel class=\"AbilityPropertyIcon prop_(.-)\">', function(key) | text = text:gsub('<Panel class=\"AbilityPropertyIcon prop_(.-)\">', function(key) | ||
local replacement = replacements[key] | local replacement = replacements[key] | ||
if replacement then | |||
local label_color = replacement.label_color or 'inherit' | |||
local icon = replacement.icon or '' | |||
local link = replacement.link or '' | |||
-- pre-process string, then check to omit link if the string is empty | |||
local translated = frame:preprocess('{{#invoke:Lang|get_string|InlineAttribute_' .. key .. '}}') | |||
if translated == '' then | |||
return string.format('<span class="no-blue-link" style="text-wrap:nowrap; font-weight:bold; color:%s;">%s</span>', label_color, icon) | |||
else | |||
return string.format('<span class="no-blue-link" style="text-wrap:nowrap; font-weight:bold; color:%s;">%s [[%s|%s]]</span>', | |||
label_color, | |||
icon, | |||
link, | |||
translated) | |||
end | |||
else | |||
return '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;" title="Missing attribute definition - Add \''..key..'\' to local replacements in [Module:Lang]">['..key..']</span>' | |||
end | |||
end) | end) | ||
-- Process citadel_inline_attribute tags | |||
text = text:gsub("{g:citadel_inline_attribute:'(.-)'}", function(key) | |||
local replacement = replacements[key] | |||
if replacement then | |||
local label_color = replacement.label_color or 'inherit' | |||
local icon = replacement.icon or '' | |||
local link = replacement.link or '' | |||
-- pre-process string, then check to omit link if the string is empty | |||
local translated = frame:preprocess('{{#invoke:Lang|get_string|InlineAttribute_' .. key .. '}}') | |||
if translated == '' then | |||
return string.format('<span class="no-blue-link" style="text-wrap:nowrap; font-weight:bold; color:%s;">%s</span>', label_color, icon) | |||
else | |||
return string.format('<span class="no-blue-link" style="text-wrap:nowrap; font-weight:bold; color:%s;">%s [[%s|%s]]</span>', | |||
label_color, | |||
icon, | |||
link, | |||
translated) | |||
end | |||
else | |||
return '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;" title="Missing attribute definition - Add \''..key..'\' to local replacements in [Module:Lang]">['..key..']</span>' | |||
end | |||
end) | |||
KEYBINDS = { | |||
Attack = '{{Mouse|1}}', | |||
ADS = '{{Mouse|2}}', | |||
AltCast = '{{Mouse|3}}', | |||
Reload = 'R', | |||
Roll = 'Shift', | |||
Mantle = 'Space', | |||
Crouch = 'Ctrl', | |||
AbilityMelee = 'Melee', | |||
Ability1 = '1', | |||
Ability2 = '2', | |||
Ability3 = '3', | |||
Ability4 = '4', | |||
MoveDown = 'Down', | |||
MoveForward = 'Forward', | |||
} | |||
-- Process | -- Process citadel_binding/citadel_keybind tags to replace with keybind strings/templates | ||
text = text:gsub("{g: | text = text:gsub("{g:citadel_binding:'(.-)'}", function(key) | ||
local replacement = KEYBINDS[key] | |||
if replacement then | |||
return replacement | |||
else | |||
return '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;" title="Missing keybind - Add \''..key..'\' to local replacements in [Module:Lang]">['..key..']</span>' | |||
end | |||
end) | |||
text = text:gsub("{g:citadel_keybind:'(.-)'}", function(key) | |||
local replacement = KEYBINDS[key] | |||
if replacement then | |||
return replacement | |||
else | |||
return '<span style="color:red;font-weight:bold;border-bottom:1px dotted red;" title="Missing keybind - Add \''..key..'\' to local replacements in [Module:Lang]">['..key..']</span>' | |||
end | |||
end) | |||
end) | |||
return frame:preprocess(text) | return frame:preprocess(text) | ||
end | end | ||