en:Module:Wd 2017年10月11日 (水) 06:56(UTC)より
template>K-iczn |
template>K-iczn (en:Module:Wd 2017年10月11日 (水) 06:56(UTC)より) |
||
208行目: | 208行目: | ||
end | end | ||
function | function errorText(code, param) | ||
local error = i18n["errors"][code] | |||
if param then error = mw.ustring.gsub(error, "$1", param) end | |||
return error | |||
end | |||
return | |||
end | end | ||
function throwError(errorMessage, param) | |||
function | error(errorText(errorMessage, param)) | ||
end | end | ||
585行目: | 566行目: | ||
-- make sure that at least one required parameter has been defined | -- make sure that at least one required parameter has been defined | ||
if not next(root.req) then | if not next(root.req) then | ||
throwError("missing-required-parameter") | |||
end | end | ||
-- make sure that the separator parameter "%s" is not amongst the required parameters | -- make sure that the separator parameter "%s" is not amongst the required parameters | ||
if root.req[parameters.separator] then | if root.req[parameters.separator] then | ||
throwError("extra-required-parameter", parameters.separator) | |||
end | end | ||
866行目: | 847行目: | ||
-- add delimiters for readability | -- add delimiters for readability | ||
value = addDelimiters(value) | value = i18n.addDelimiters(value) | ||
end | end | ||
921行目: | 902行目: | ||
end | end | ||
suffix = getOrdinalSuffix(yRound) .. suffix | suffix = i18n.getOrdinalSuffix(yRound) .. suffix | ||
else | else | ||
-- if not verbose, take the first year of the century/millennium | -- if not verbose, take the first year of the century/millennium | ||
1,219行目: | 1,200行目: | ||
itemID = "P" .. itemID | itemID = "P" .. itemID | ||
else | else | ||
return '<strong class="error">' .. | return '<strong class="error">' .. errorText('unknown-data-type', snak.datatype) .. '</strong>' | ||
end | end | ||
1,230行目: | 1,211行目: | ||
return label | return label | ||
else | else | ||
return '<strong class="error">' .. | return '<strong class="error">' .. errorText('unknown-data-type', snak.datavalue.type) .. '</strong>' | ||
end | end | ||
elseif snak.snaktype == 'somevalue' and not noSpecial then | elseif snak.snaktype == 'somevalue' and not noSpecial then | ||
2,531行目: | 2,512行目: | ||
if not frame.args[1] then | if not frame.args[1] then | ||
throwError("no-function-specified") | |||
end | end | ||
2,537行目: | 2,518行目: | ||
if f == "main" then | if f == "main" then | ||
throwError("main-called-twice") | |||
end | end | ||
assert(p["_"..f], | assert(p["_"..f], errorText('no-such-function', f)) | ||
-- copy arguments from immutable to mutable table | -- copy arguments from immutable to mutable table |