Difference between revisions of "Module:TNT"

Jump to navigation Jump to search
fix doc translation link
en>Yurik
(no auto I18n/ prefix, breaks some graphs)
en>Yurik
(fix doc translation link)
Line 39: Line 39:


-- Forward declaration of the local functions
-- Forward declaration of the local functions
local formatMessage, loadData, link
local sanitizeDataset, loadData, link, formatMessage


function p.msg(frame)
function p.msg(frame)
Line 75: Line 75:


function p.doc(frame)
function p.doc(frame)
return frame:extensionTag(
local dataset = 'Templatedata/' .. sanitizeDataset(frame.args[1])
'templatedata',
return frame:extensionTag('templatedata', p.getTemplateData(dataset)) ..
p.getTemplateData(mw.text.trim(frame.args[1]))
  formatMessage(i18nDataset, 'edit_doc', {link(dataset)})
) .. formatMessage(i18nDataset, 'edit_doc', {link(dataset)})
end
end


function p.getTemplateData(page)
function p.getTemplateData(dataset)
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 124: Line 122:


-- Local functions
-- Local functions
sanitizeDataset = function(dataset)
if not dataset then
return nil
end
dataset = mw.text.trim(dataset)
if dataset == '' then
return nil
elseif string.sub(dataset,-4) ~= '.tab' then
return dataset .. '.tab'
else
return dataset
end
end


loadData = function(dataset, lang)
loadData = function(dataset, lang)
if not dataset or dataset == '' then
dataset = sanitizeDataset(dataset)
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


Anonymous user

Navigation menu