모듈:usex/templates/연습장
보이기
이 모듈에 대한 설명문서는 모듈:usex/templates/연습장/설명문서에서 만들 수 있습니다
local export = {}
local m_languages = require("Module:languages")
local table_module = "Module:table"
local usex_module = "Module:usex"
local rsplit = mw.text.split
local rfind = mw.ustring.find
local function track(page)
require("Module:debug/track")("usex/templates/" .. page)
return true
end
function export.fetch_categories(lang, param)
-- 분류 테이블 생성
local categories = {}
-- 분류 삽입 함수
local function insert_cat(cat)
table.insert(categories, cat)
end
insert_cat("구식화된 예문 매개변수 [" .. param .. "] 사용/" .. lang)
return categories
end
function export.usex_t(frame)
-- Invocation arguments (passed in the template #invoke call).
local iparams = {
["quote"] = {},
["compat"] = {type = "boolean"},
["inline"] = {type = "boolean"},
["nocat"] = {type = "boolean"},
["class"] = {},
}
local iargs = require("Module:parameters").process(frame.args, iparams)
local compat = iargs.compat
-- Template (parent) arguments.
local params = {
-- Usex/quotation text parameters
[1] = {},
["언어"] = {},
["예문"] = {},
[2] = {alias_of = "예문"},
["termlang"] = {},
["tr"] = {},
["transliteration"] = {alias_of = "tr"},
["ts"] = {},
["transcription"] = {alias_of = "ts"},
["sc"] = {},
["norm"] = {},
["normalization"] = {alias_of = "norm"},
["normsc"] = {},
["subst"] = {},
["q"] = {list = true},
["qualifier"] = {alias_of = "q"},
["qq"] = {list = true},
["ref"] = {},
-- Translation of usex text
[3] = {},
["t"] = {alias_of = 3},
["translation"] = {alias_of = 3},
["lit"] = {},
-- Original text, if the usex/quotation is a translation
["orig"] = {},
["origlang"] = {},
["origtr"] = {},
["origts"] = {},
["origsc"] = {},
["orignorm"] = {},
["orignormsc"] = {},
["origsubst"] = {},
["origq"] = {list = true},
["origqq"] = {list = true},
["origref"] = {},
-- Citation-related parameters; for anything more complex, usex {{quote-*}}
["source"] = {},
["footer"] = {},
-- Formatting parameters
["inline"] = {type = "boolean"},
["brackets"] = {type = "boolean"},
-- Categorization parameters
["nocat"] = {type = "boolean"},
["sort"] = {},
}
-- 구식화된 매개변수를 위한 딕셔너리 생성
local desperatedParams = {
["언어"] = false,
["원문"] = false,
["발음"] = false,
["외래어표기법"] = false,
["외국말적기법"] = false
}
if compat then
params["lang"] = {required = true}
params["t"].alias_of = 2
params["translation"].alias_of = 2
table.remove(params, 1)
end
local args = require("Module:parameters").process(frame:getParent().args, params)
local langparam = compat and "lang" or 1
local lang = m_languages.getByCode(args[langparam] or "und", langparam, "allow etym")
local sc = args.sc
sc = sc and require("Module:scripts").getByCode(sc, "sc") or nil
local normsc = args.normsc
normsc = normsc == "auto" and normsc or normsc and require("Module:scripts").getByCode(normsc, "normsc") or nil
if normsc and not args.norm then
error("Cannot specify normsc= without norm=")
end
if #args.qq > 0 then
track("qq")
end
if #args.q > 0 then
track("q")
end
local termlang
if args.termlang then
termlang = m_languages.getByCode(args.termlang, "termlang", "allow etym")
table.insert(args.qq, 1, "in " .. lang:getCanonicalName())
end
local origlang, origsc, orignormsc
if args.orig then
origlang = m_languages.getByCode(args.origlang, "origlang", "allow etym")
table.insert(args.origqq, 1, "in " .. origlang:getCanonicalName())
origsc = args.origsc
origsc = origsc and require("Module:scripts").getByCode(origsc, "origsc") or nil
orignormsc = args.orignormsc
orignormsc = orignormsc == "auto" and orignormsc or
orignormsc and require("Module:scripts").getByCode(orignormsc, "normsc") or nil
if orignormsc and not args.orignorm then
error("Cannot specify orignormsc= without orignorm=")
end
else
for _, noparam in ipairs { "origlang", "origtr", "origts", "origsc", "orignorm", "orignormsc", "origsubst",
"origref" } do
if args[noparam] then
error(("Cannot specify %s= without orig="):format(noparam))
end
end
if #args.origq > 0 then
error("Cannot specify origq= without orig=")
end
if #args.origqq > 0 then
error("Cannot specify origqq= without orig=")
end
end
local data = {
lang = lang,
sc = sc,
normsc = normsc,
usex = args[compat and 1 or 2],
translation = args[compat and 2 or 3],
transliteration = args.tr,
transcription = args.ts,
normalization = args.norm,
inline = args.inline or iargs.inline,
ref = args.ref,
quote = iargs.quote,
lit = args.lit,
subst = args.subst,
-- FIXME, change to left and right qualifiers
qq = #args.qq > 0 and args.qq or args.q,
source = args.source,
footer = args.footer,
nocat = args.nocat or iargs.nocat,
brackets = args.brackets,
sortkey = args.sort,
class = iargs.class,
-- Original text, if the usex/quotation is a translation
orig = args.orig,
origlang = origlang,
origtr = args.origtr,
origts = args.origts,
origsc = origsc,
orignorm = args.orignorm,
orignormsc = orignormsc,
origsubst = args.origsubst,
origq = args.origq,
origqq = args.origqq,
origref = args.origref,
}
return require(usex_module).format_usex(data)
end
local ignore_prefixes = {"사용자:", "토론:",
"위키낱말사전:자유게시판", "Wiktionary:Translation requests",
"Wiktionary:Grease pit", "Wiktionary:Etymology scriptorium",
"Wiktionary:Information desk", "Wiktionary:Tea room",
"Wiktionary:Requests for", "Wiktionary:Votes"
}
function export.page_should_be_ignored(page)
-- Ignore user pages, talk pages and certain Wiktionary pages
for _, ip in ipairs(ignore_prefixes) do
if rfind(page, "^" .. ip) then
return true
end
end
if rfind(page, " talk:") then
return true
end
return false
end
function export.page_should_be_ignored_t(frame)
return export.page_should_be_ignored(frame.args[1]) and "true" or ""
end
return export