Module:languages/templates
- De neikommende dokumintaasje stiet op Module:languages/templates/dokumintaasje. [bewurkje]
Oernommen fan en:Module:languages/templates.
Oerset:
- foutmeldingen
local export = {}
function export.exists(frame)
local args = frame.args
local lang = args[1] or error("Taalkoade is net opjûn. Jou a.j.w. parameter 1 by it oanroppen fan 'e module.")
lang = require("Module:languages").getByCode(lang)
if lang then
return "1"
else
return ""
end
end
-- Used by the following JS:
-- * [[WT:ACCEL]]
-- * [[WT:EDIT]]
-- * [[WT:NEC]]
function export.getByCode(frame)
local args = frame.args
local langcode = args[1] or error("Taalkoade is net opjûn. Jou a.j.w. parameter 1 by it oanroppen fan 'e module.")
local itemname = args[2] or error("Op te sykjen ynformaasjesoarte is net opjûn. Jou a.j.w. parameter 2 by it oanroppen fan 'e module.")
local lang = require("Module:languages").getByCode(langcode)
if not lang then
error("De taalkoade '" .. langcode .. "' is net jildich.")
end
-- The item that the caller wanted to look up
if itemname == "getOtherNames" then
local index = args[3]; if index == "" then index = nil end
index = tonumber(index) or error("Jou a.j.w. de numerike yndeks op fan 'e winske namme.")
return lang:getOtherNames()[index] or ""
elseif itemname == "getFamily" then
return lang:getFamily():getCode()
elseif itemname == "getWikimediaLanguages" then
local index = args[3]; if index == "" then index = nil end
index = tonumber(index) or error("Jou a.j.w. de numerike yndeks op fan 'e winske taal.")
local langs = lang:getWikimediaLanguages()
if langs[index] then
return langs[index]:getCode()
else
return ""
end
elseif itemname == "getScripts" then
local index = args[3]; if index == "" then index = nil end
index = tonumber(index) or error("Jou a.j.w. de numerike yndeks op fan it winske skrift.")
local scripts = lang:getScriptCodes()
if scripts[index] then
return scripts[index]
else
return ""
end
elseif itemname == "getAncestors" then
local index = args[3]; if index == "" then index = nil end
index = tonumber(index) or error("Jou a.j.w. de numerike yndeks op fan 'e winske foargonger.")
local ancestors = lang:getAncestors()
if ancestors[index] then
return ancestors[index]:getCode()
else
return ""
end
elseif itemname == "transliterate" then
local text = args[3]; if text == "" then text = nil end
local sc = args[4]; if sc == "" then sc = nil end
local module_override = args[5]; if module_override == "" then module_override = nil end
sc = (sc and (require("Module:scripts").getByCode(sc) or error("De skriftkoade \"" .. sc .. "\" is net jildich.")) or nil)
return lang:transliterate(text, sc, module_override) or ""
elseif itemname == "makeEntryName" then
local text = args[3]; if text == "" then text = nil end
return lang:makeEntryName(text) or ""
elseif itemname == "makeSortKey" then
local text = args[3]; if text == "" then text = nil end
return lang:makeSortKey(text) or ""
elseif lang[itemname] then
local ret = lang[itemname](lang)
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 langname = args[1] or error("Taalnamme is net opjûn. Jou a.j.w. parameter 1 by it oanroppen fan 'e module.")
local lang = require("Module:languages").getByCanonicalName(langname)
if lang then
return lang:getCode()
else
return ""
end
end
function export.getByName(frame)
local args = frame.args
local langname = args[1] or error("Taalnamme is net opjûn. Jou a.j.w. parameter 1 by it oanroppen fan 'e module.")
local lang = require("Module:languages").getByName(langname)
if lang then
return lang:getCode()
else
return ""
end
end
function export.makeEntryName(frame)
local args = frame.args
local langname = args[1] or error("Taalnamme is net opjûn. Jou a.j.w. parameter 1 by it oanroppen fan 'e module.")
local lang = require("Module:languages").getByCode(langname)
if lang then
return lang:makeEntryName(args[2])
else
return ""
end
end
function export.getCanonicalName(frame)
local langCode
if require("Module:yesno")(frame.args.parent) then
langCode = frame:getParent().args[1]
else
langCode = frame.args[1]
end
if not langCode or langCode == "" then
error("Set in taalkoade yn parameter 1.")
end
return mw.loadData("Module:languages/code to canonical_name")[langCode] or ""
end
return export