Editing Module:TNT
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 38: | Line 38: | ||
-- Forward declaration of the local functions | -- Forward declaration of the local functions | ||
local | local formatMessage, loadData, link | ||
function p.msg(frame) | function p.msg(frame) | ||
Line 87: | Line 87: | ||
function p.doc(frame) | function p.doc(frame) | ||
return frame:extensionTag( | |||
'templatedata', | |||
p.getTemplateData(mw.text.trim(frame.args[1])) | |||
) .. formatMessage(i18nDataset, 'edit_doc', {link(dataset)}) | |||
end | end | ||
function p.getTemplateData(dataset) | function p.getTemplateData(page) | ||
dataset = 'Templatedata/' .. mw.text.trim(page) | |||
-- TODO: add '_' parameter once lua starts reindexing properly for "all" languages | -- TODO: add '_' parameter once lua starts reindexing properly for "all" languages | ||
local data = loadData(dataset) | local data = loadData(dataset) | ||
Line 133: | Line 135: | ||
-- Local functions | -- Local functions | ||
loadData = function(dataset, lang) | loadData = function(dataset, lang) | ||
if not dataset or dataset == '' then | |||
if not dataset then | |||
error(formatMessage(i18nDataset, 'error_no_dataset', {})) | error(formatMessage(i18nDataset, 'error_no_dataset', {})) | ||
end | |||
if string.sub(dataset,-4) ~= '.tab' then | |||
dataset = dataset .. '.tab' | |||
end | end | ||