Module:scripts/templates
- De neikommende dokumintaasje stiet op Module:scripts/templates/dokumintaasje. [bewurkje]
Oernommen fan en:Module:scripts/templates.
Oerset:
- foutmeldingen
local export = {}
function export.exists(frame)
local args = frame.args
local sc = args[1] or error("Skriftkoade is net opjûn. Jou a.j.w. parameter 1 by it oanroppen fan 'e module.")
sc = require("Module:scripts").getByCode(sc)
if sc then
return "1"
else
return ""
end
end
function export.getByCode(frame)
local args = frame.args
local sc = args[1] or error("Skriftkoade (parameter 1) is net opjûn.")
local itemname = args[2] or error("Oan te roppen funksje (parameter 2) is net opjûn.")
sc = require("Module:scripts").getByCode(sc) or error("De skriftkoade '" .. sc .. "' is net jildich.")
-- The item that the caller wanted to look up
if itemname == "getCanonicalName" then
return sc:getCanonicalName()
elseif itemname == "getOtherNames" then
local index = args[3]; if index == "" then index = nil end
index = tonumber(index or error("Numerike yndeks fan it winske item yn 'e list (parameter 3) is net opjûn."))
return sc:getOtherNames()[index] or ""
elseif itemname == "getCategoryName" then
return sc:getCategoryName()
elseif itemname == "countCharacters" then
local text = args[3] or ""
return sc:countCharacters(text)
elseif sc[itemname] then
local ret = sc[itemname](sc)
if type(ret) == "string" then
return ret
else
error("De funksje \"" .. itemname .. "\" joech gjin tekenrige as wearde.")
end
else
error("Unjildige itemnamme \"" .. itemname .. "\" opfrege.")
end
end
function export.getByCanonicalName(frame)
local args = frame.args
local sc = args[1] or error("Skriftnamme (parameter 1) is net opjûn.")
sc = require("Module:scripts").getByCanonicalName(sc)
if sc then
return sc:getCode()
else
return "None"
end
end
function export.findBestScript(frame)
local args = frame.args
local text = args[1] or error("Te analysearjen tekst (parameter 1) is net opjûn.")
local lang = args[2] or error("Taalkoade (parameter 2) is net opjûn.")
lang = require("Module:languages").getByCode(lang) or error("De taalkoade \"" .. lang .. "\" is net jildich.")
return require("Module:scripts").findBestScript(text, lang):getCode()
end
return export