Modul:etymology/specialized
Tampilan
Dokumentasi untuk modul ini dapat dibuat di Modul:etymology/specialized/doc
local export = {}
-- This function handles all the messiness of different types of specialized borrowings. It should insert any
-- borrowing-type-specific categories into `categories` unless `nocat` is given, and return the text to display
-- before the source + term (or "" for no text).
function export.get_specialized_borrowing_text_insert_cats(bortype, categories, lang, source, nocap, nocat, senseid)
local function non_glossary_link(entry, text)
text = text or entry
if not nocap and not senseid then
text = mw.getContentLanguage():ucfirst(text)
end
if senseid then
senseids = mw.text.split(senseid, '!!')
output = {}
for i, id in ipairs(senseids) do
if i == 1 and not nocap then
uc = '|uc=1'
else
uc = ''
end
table.insert(output, mw.getCurrentFrame():preprocess('{{senseno|' .. lang:getCode() .. '|' .. id .. uc .. '}}'))
end
if senseid:find('!!') then
copula = ' are '
article = ''
plural = 's'
else
copula = ' is '
article = ' a '
plural = ''
end
return mw.text.listToText(output) .. copula .. article .. '[[' .. entry .. '|' .. text .. plural .. ']]'
else
return "[[" .. entry .. "|" .. text .. "]]"
end
end
local function glossary_link(entry, text)
text = text or entry
return non_glossary_link("Lampiran:Glosarium#" .. entry, text)
end
local function inscat(cat)
table.insert(categories, "Lema " .. lang:getCanonicalName() .. " " .. cat)
end
local text, category
if bortype == "calque" then
text = glossary_link("pinjam terjemah") .. " dari "
category = " yang dipinjam-terjemah dari "
elseif bortype == "partial-calque" then
text = glossary_link("pinjam terjemah sebagian") .. " dari "
category = " yang dipinjam-terjemah sebagian dari "
elseif bortype == "semantic-loan" then
text = glossary_link("pinjam semantik") .. " dari "
category = " yang pinjam semantik dari "
elseif bortype == "transliteration" then
text = glossary_link("transliterasi") .. " dari "
category = "transliterasi dari lema SOURCE"
-- It seems the intent of the former code was to insert two categories, but it never worked.
-- if not nocat then
-- inscat(" terms borrowed from " .. source:getDisplayForm())
-- end
elseif bortype == "phono-semantic-matching" then
text = glossary_link("pasangan fono-semantik") .. " dari "
category = "pasangan fono-semantik dari "
else
local lang_is_source = lang:getCode() == source:getCode()
if not nocat then
if lang_is_source then
inscat(" yang pinjam-ganda")
else
if bortype == "learned" then
category2 = " diserap utuh "
elseif bortype == "semi-learned" then
category2 = " diserap sebagian "
elseif bortype == "orthographic" then
category2 = " diserap ortografis "
elseif bortype == "unadapted" then
category2 = " diserap "
else
error("Galat internal: tipe (bortype) tidak dikenal: " .. bortype)
end
inscat(" yang dipinjam dari " .. source:getDisplayForm())
category = " yang " .. category2 .. " dari "
end
end
if bortype == "learned" then
text = glossary_link("pinjaman") .. " dari "
elseif bortype == "semi-learned" then
text = glossary_link("semi-pinjaman") .. " dari "
elseif bortype == "orthographic" then
text = glossary_link("peminjaman ortografis") .. " dari "
elseif bortype == "unadapted" then
text = glossary_link("peminjaman utuh") .. " dari "
else
error("Galat internal: tipe (bortype) tidak dikenal: " .. bortype)
end
end
if category and not nocat then
local sourcedisp = source:getDisplayForm()
if category:find("SOURCE") then
category = category:gsub("SOURCE", sourcedisp)
else
category = category .. sourcedisp
end
inscat(category)
end
return text
end
function export.specialized_borrowing(bortype, lang, terminfo, sort_key, nocap, notext, nocat, senseid, template_name)
local m_etymology = require("Module:etymology")
local categories = {}
local source = terminfo.lang
local text = export.get_specialized_borrowing_text_insert_cats(bortype, categories, lang, source, nocap, nocat, senseid)
text = notext and "" or text
return text .. m_etymology.format_etyl(lang, source, sort_key, categories, nocat) ..
m_etymology.process_and_create_link(terminfo, template_name)
end
function export.specialized_multi_borrowing(bortype, lang, sc, sources, terminfo, sort_key, nocap, notext, nocat, conj, senseid, template_name)
local categories = {}
local text
for _, source in ipairs(sources) do
text = export.get_specialized_borrowing_text_insert_cats(bortype, categories, lang, source, nocap, nocat, senseid)
end
text = notext and "" or text
return text .. require("Module:etymology/multi").format_sources(lang, sc, sources, terminfo, sort_key, categories, nocat, conj) ..
require("Module:etymology").process_and_create_link(terminfo, template_name)
end
return export