Modul:links/templates: Redaktələr arasındakı fərq

Silinən məzmun Əlavə edilmiş məzmun
270899 dəyişikliyi Aabdullayev851 (Müzakirə) tərəfindən geri alındı.
Redaktənin izahı yoxdur
 
Sətir 1:
local m_links = require("Module:links")
 
local export = {}
 
--[=[
-- Used in [[Template:l]] and [[Template:m]]
Modules used:
[[Module:links]]
[[Module:languages]]
[[Module:scripts]]
[[Module:parameters]]
[[Module:debug]]
]=]
 
-- Used in [[Template:l]] and [[Template:m]].
function export.l_term_t(frame)
local face = frame.args["face"]
Sətir 13 ⟶ 20:
[3] = {},
[4] = {alias_of = "gloss"},
["accel"] = {},
["g"] = {list = true},
["gloss"] = {},
Sətir 18 ⟶ 26:
["lit"] = {},
["pos"] = {},
["t"] = {alias_of = "gloss"},
["tr"] = {},
["ts"] = {},
["sc"] = {},
}
Sətir 50 ⟶ 60:
-- Check parameters
lang = require("Module:languages").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.")
require("Module:languages").err(lang, 1)

if sc = (then
sc and= (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
end
if not term and not alt and frame.args["demo"] then
Sətir 58 ⟶ 72:
-- Forward the information to full_link
return require("Module:links").full_link(
return m_links.full_link({lang = lang, sc = sc, term = term, alt = alt, id = args["id"], tr = args["tr"], genders = args["g"], gloss = args["gloss"], pos = args["pos"], lit = args["lit"]}, face, allowSelfLink)
{
lang = lang,
sc = sc,
term = term,
alt = alt,
id = args["id"],
tr = args["tr"],
ts = args["ts"],
genders = args["g"],
gloss = args["gloss"],
pos = args["pos"],
lit = args["lit"],
accel = args["accel"] and string.gsub(args["accel"], "_", "|"), -- To allow use of | in templates
},
face,
allowSelfLink
)
end
 
-- Used in [[Template:ll]].
function export.ll(frame)
local argsparams = frame:getParent().args{
[1] = { required = true },
local allowSelfLink = args["notself"]; allowSelfLink = not allowSelfLink or allowSelfLink == ""
[2] = { allow_empty = true },
[3] = {},
["notself"] = { type = "boolean", default = false },
["id"] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local allowSelfLink = not args["notself"]
local lang = args[1]
lang = require("Module:languages").getByCode(lang) or errorrequire("The language code \Module:languages"" ).. err(lang, .. "\" is not valid."1)
local text = args[2]
local alt = args[3]
if text == "" then
return alt or ""
end
if alt == "" then alt = nil end
local id = args["id"]; if id == "" then id = nil end
return m_linksrequire("Module:links").language_link(text, alt, lang, id, allowSelfLink)
{
term = text,
alt = alt,
lang = lang,
id = id
},
allowSelfLink
)
end
 
Sətir 85 ⟶ 133:
local args = require("Module:parameters").process(frame:getParent().args, params)
return m_linksrequire("Module:links").english_links(args[1])
end
 
 
function export.linkify_t(frame)
local params = {
[1] = {required = true, default = ""},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
args[1] = mw.text.trim(args[1])
if args[1] == "" or args[1]:find("[[", nil, true) then
return args[1]
else
return "[[" .. args[1] .. "]]"
end
end
 
function export.section_link_t(frame)
local params = {
[1] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
return require("Module:links").section_link(args[1])
end
 
function export.language_name_link_t(frame)
local face = frame.args["face"]
local allowSelfLink = frame.args["notself"]; allowSelfLink = not allowSelfLink or allowSelfLink == ""
local params = {
[1] = {required = true},
[2] = {},
[3] = {},
[4] = {alias_of = "gloss"},
["g"] = {list = true},
["gloss"] = {},
["id"] = {},
["lit"] = {},
["pos"] = {},
["t"] = {alias_of = "gloss"},
["tr"] = {},
["ts"] = {},
["sc"] = {},
["w"] = { type = "boolean", default = false },
}
-- Compatibility mode for {{term}}.
-- If given a nonempty value, the function uses lang= to specify the
-- language, and all the positional parameters shift one number lower.
local compat = (frame.args["compat"] or "") ~= ""
if compat then
params["lang"] = {},
table.remove(params, 1)
end
local args = require("Module:parameters").process(frame:getParent().args, params)
local lang = args[compat and "lang" or 1]
-- Tracking for missing language or und
if not lang then
require("Module:debug").track("link/no lang")
elseif lang == "und" then
require("Module:debug").track("link/und")
end
lang = lang or "und"
local sc = args["sc"]
local term = args[(compat and 1 or 2)]
local alt = args[(compat and 2 or 3)]
-- Check parameters
lang = require("Module:languages").getByCode(lang) or
require("Module:languages").err(lang, 1)
if sc then
sc = require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")
end
if not term and not alt and frame.args["demo"] then
term = frame.args["demo"]
end
--[[
Add a language name, linked to Wikipedia if the Wikipedia parameter is set to true.
Forward the information to full_link.
]]
return ( args.w and lang:makeWikipediaLink() or lang:getCanonicalName() ) .. " " ..
require("Module:links").full_link(
{
lang = lang,
sc = sc,
term = term,
alt = alt,
id = args["id"],
tr = args["tr"],
ts = args["ts"],
genders = args["g"],
gloss = args["gloss"],
pos = args["pos"],
lit = args["lit"]
},
face,
allowSelfLink
)
end
 
function export.light_link_t(frame)
local params = {
[1] = { required = true },
[2] = { required = true },
[3] = {},
["sc"] = {},
["langname"] = { required = true },
}
local args = frame:getParent().args
for key, value in pairs (params) do
if value.required then
if not args[key] then
error('Parameter "' .. key .. '" is required.')
end
end
end
return require("Module:links").light_link{
langCode = args[1],
term = args[2],
alt = args[3],
scCode = args.sc or "Latn",
langName = args.langname
}
end