မဝ်ဂျူ:etymology: အရာမတၞဟ်ခြာ အကြာ မူတၞဟ်ဂမၠိုင်

နူ ဝိက်ရှေန်နရဳ
Content deleted Content added
No edit summary
No edit summary
ဒစင်: မကလေၚ်ပလေဝ်ဒါန်လဝ်
လာင် ၄- လာင် ၄-
local force_cat = false
local force_cat = false


local function term_error(terminfo)
--[[ If language is an etymology language, iterates through parent languages
if terminfo.lang:hasType("family") then
until it finds a non-etymology language. ]]
function export.getNonEtymological(lang)
while lang:getType() == "etymology language" do
local parentCode = lang:getParentCode()
local parent = require("Module:languages").getByCode(parentCode)
or require("Module:etymology languages").getByCode(parentCode)
or require("Module:families").getByCode(parentCode)
lang = parent
-- mw.log(terminfo.lang:getCode() .. " " .. terminfo.lang:getType())
end
return lang
end


local function termError(terminfo)
if terminfo.lang:getType() == "family" then
if terminfo.term and terminfo.term ~= "-" then
if terminfo.term and terminfo.term ~= "-" then
require("Module:debug").track("etymology/family/has-term")
require("Module:debug/track")("etymology/family/has-term")
end
end
လာင် ၃၃- လာင် ၁၆-




local function createLink(terminfo, templateName)
local function create_link(terminfo, template_name)
local link = ""
local link = ""
လာင် ၄၃- လာင် ၂၆-
[[Special:WhatLinksHere/Template:tracking/calque/no-term]]
[[Special:WhatLinksHere/Template:tracking/calque/no-term]]
]=]
]=]
require("Module:debug").track(templateName .. "/no-term")
require("Module:debug/track")(template_name .. "/no-term")
else
else
-- mw.log(terminfo.term)
-- mw.log(terminfo.term)
လာင် ၅၃- လာင် ၃၆-




function export.format_etyl(lang, source, sort_key, categories, nocat)
function export.process_and_create_link(terminfo, template_name)
terminfo = term_error(terminfo)
local info = {}
return create_link(terminfo, template_name or "derived")
end
-- [[Special:WhatLinksHere/Template:tracking/etymology/sortkey]]
if sort_key then
require("Module:debug").track("etymology/sortkey")
end

if not categories then
if not categories then
categories = {}
categories = {}
လာင် ၈၉- လာင် ၆၉-
info.cat_name = source:getCanonicalName()
info.cat_name = source:getCanonicalName()
end
end

end
return display, cat_name
end
-- Add the categories, but only if there is a current language


function export.insert_source_cat_get_display(categories, lang, source, raw, nocat)
local display, cat_name = export.get_display_and_cat_name(source, raw)

if lang and not nocat then
if lang and not nocat then
-- Add the category, but only if there is a current language
local m_utilities = require("Module:utilities")
if not categories then
categories = {}
end
if lang:getCode() == source:getCode() then
if lang:getCode() == source:getCode() then
table.insert(categories,"ဝေါဟာ".. lang:getCanonicalName() .. " လွဳၜါလောန်ဂမၠိုင်")
--table.insert(categories, lang:getCanonicalName() .. " twice-borrowed terms")
table.insert(categories,"ဝေါဟာ".. lang:getCanonicalName() .. "လွဳၜါလောန်ဂမၠိုင်")
else
else
table.insert(categories,"ဝေါဟာ".. lang:getCanonicalName() .."ကၠုင်နူဝေါဟာ" .. source:getCanonicalName() .. "ဂမၠိုင်")
--table.insert(categories, lang:getCanonicalName() .. " terms derived from " .. cat_name)
table.insert(categories, "ဝေါဟာ" .. lang:getCategoryName() .. "မဆက်ဆေန်ကၠုၚ်နူဝေါဟာ" .. cat_name)
end
end
end

categories = m_utilities.format_categories(categories, lang, sort_key, nil, force_cat)
return display, categories
end


-- FIXME: rename to format_source()
function export.format_etyl(lang, source, sort_key, categories, nocat)
-- [[Special:WhatLinksHere/Template:tracking/etymology/sortkey]]
if sort_key then
require("Module:debug/track")("etymology/sortkey")
end

local display
display, categories = export.insert_source_cat_get_display(categories, lang, source, false, nocat)
if lang and not nocat then
-- Format categories, but only if there is a current language; {{cog}} currently gets no categories
categories = require("Module:utilities").format_categories(categories, lang, sort_key, nil, force_cat)
else
else
categories = ""
categories = ""
end
end
return "<span class=\"etyl\">" .. info.display .. categories .. "</span>"
return "<span class=\"etyl\">" .. display .. categories .. "</span>"
end
end


လာင် ၁၁၈- လာင် ၁၂၃-


-- Internal implementation of {{derived|...}} template
-- Internal implementation of {{derived|...}} template
function export.format_derived(lang, terminfo, sort_key, nocat, templateName)
function export.format_derived(lang, terminfo, sort_key, nocat, template_name)
local source = terminfo.lang
local source = terminfo.lang
return export.format_etyl(lang, source, sort_key, nil, nocat) .. export.process_and_create_link(terminfo, template_name)
terminfo.lang = export.getNonEtymological(terminfo.lang)

terminfo = termError(terminfo)
local link = createLink(terminfo, templateName or "derived")
return export.format_etyl(lang, source, sort_key, nil, nocat) .. link
end
end


-- Check that `lang` has `otherlang` (which may be an etymology-only language) as an ancestor. Throw an error if not.

local function check_ancestor(lang, otherlang)
-- Internal implementation of {{inherited|...}} template
if not lang:hasAncestor(otherlang) and mw.title.getCurrentTitle().nsText ~= "แม่แบบ" then
function export.format_inherited(lang, terminfo, sort_key, nocat)
-- Generate the non-ancestor error message.
local source = terminfo.lang

terminfo = termError(terminfo)
terminfo.lang = export.getNonEtymological(terminfo.lang)

if not lang:hasAncestor(terminfo.lang) and mw.title.getCurrentTitle().nsText ~= "Template" then
local function showLanguage(lang)
local function showLanguage(lang)
local retval = ("%s (%s)"):format(lang:makeCategoryLink(), lang:getCode())
return ("[[:Category:%s|%s]] (%s)")
if lang:hasType("etymology-only") then
:format(lang:getCategoryName(), lang:getCanonicalName(), lang:getCode())
retval = retval .. (" (an etymology-only language whose regular parent is %s)"):format(
showLanguage(lang:getParent()))
end
return retval
end
end
local postscript
local postscript
လာင် ၁၆၂- လာင် ၁၅၈-
end
end
error(("%s is not set as an ancestor of %s in %s. %s")
error(("%s is not set as an ancestor of %s in %s. %s")
:format(showLanguage(terminfo.lang), showLanguage(lang), moduleLink, postscript))
:format(showLanguage(otherlang), showLanguage(lang), moduleLink, postscript))
end
end
end


-- Internal implementation of {{inherited|...}} template
function export.format_inherited(lang, terminfo, sort_key, nocat)
local source = terminfo.lang
local categories = {}
local categories = {}
if not nocat then
--table.insert(categories, lang:getCanonicalName() .. " terms inherited from " .. source:getCanonicalName())
local link = createLink(terminfo, "inherited")
table.insert(categories,"ဝေါဟာ".. lang:getCanonicalName() .. "ဂွံလဝ်အာဲကၟာဲနူဝေါဟာ" .. source:getCanonicalName() .. "ဂမၠိုင်")
table.insert(categories,"ဝေါဟာ".. lang:getCanonicalName() .. "ဂွံလဝ်အာဲကၟာဲနူဝေါဟာ" .. source:getCanonicalName() .. "ဂမၠိုင်")
end

local link = export.process_and_create_link(terminfo, "inherited")
check_ancestor(lang, source)

return export.format_etyl(lang, source, sort_key, categories, nocat) .. link
return export.format_etyl(lang, source, sort_key, categories, nocat) .. link
end
end




function export.insert_borrowed_cat(categories, lang, source)
-- Internal implementation of {{borrowed|...}} template
local category
function export.format_borrowed(lang, terminfo, sort_key, nocap, notext, nocat, borrowing_type)
local source = terminfo.lang
terminfo.lang = export.getNonEtymological(terminfo.lang)
terminfo = termError(terminfo)
local text = ""
local categories = {}

if lang:getCode() == source:getCode() then
if lang:getCode() == source:getCode() then
--category = " twice-borrowed terms"
table.insert(categories,"ဝေါဟာ".. lang:getCanonicalName() .. "လွဳၜါလောန်ဂမၠိုင်")
table.insert(categories,"ဝေါဟာ".. lang:getCanonicalName() .. "လွဳၜါလောန်ဂမၠိုင်")
elseif source:getType() == "family" then
table.insert(categories,"ဝေါဟာ" .. lang:getCanonicalName() .. "လွဳလဝ် နူဝေါဟာ" .. source:getCategoryName() .. "ဂမၠိုင်")
else
else
--category = " terms borrowed from " .. source:getDisplayForm()
table.insert(categories,"ဝေါဟာ" .. lang:getCanonicalName() .. "လွဳလဝ် နူဝေါဟာ" .. source:getCategoryName() .. "ဂမၠိုင်")
table.insert(categories,"ဝေါဟာ" .. lang:getCanonicalName() .. "လွဳလဝ် နူဝေါဟာ" .. source:getCategoryName() .. "ဂမၠိုင်")
end
end
--table.insert(categories, lang:getCanonicalName() .. category)

table.insert(categories, category)
if not notext then
if borrowing_type == "learned" then
text = "လွဳလဝ်ဗီုကတ်လ္ၚတ်နူဝေါဟာ"
elseif borrowing_type == "semi-learned" then
text = "[[semi-learned borrowing|" .. (nocap and "s" or "S") .. "emi-learned borrowing]] from "
elseif borrowing_type == "orthographic" then
text = "လွဳလဝ်ဗီုနဲအက္ခဝ်နူဝေါဟာ"
elseif borrowing_type == "unadapted" then
text = "လွဳလဝ်ဗီုဟွံပါလ္ပာ်ပြံၚ်လှာဲနူဝေါဟာ"
else
text = "လွဳလဝ်နူဝေါဟာ"
end
end

if borrowing_type ~= "plain" and lang:getCode() ~= source:getCode() then
-- For non-plain borrowings, insert extra category, unless lang and source
-- are the same (a twice-borrowed term).
local source_name = source:getType() == "family" and source:getCategoryName() or source:getCanonicalName()
table.insert(categories, lang:getCanonicalName() .. " " .. borrowing_type .. " borrowings from " .. source_name)
end
local link = createLink(terminfo, "borrowed")
return text .. export.format_etyl(lang, source, sort_key, categories, nocat) .. link
end
end




-- Internal implementation of {{borrowed|...}} template.
local function specialized_borrowing(lang, terminfo, sort_key, nocat, pre_text, template_name, category)
function export.format_borrowed(lang, terminfo, sort_key, nocat)
local result = pre_text
local source = terminfo.lang
local source = terminfo.lang
terminfo.lang = export.getNonEtymological(terminfo.lang)

terminfo = termError(terminfo)

local categories = {}
local categories = {}
if not nocat then

export.insert_borrowed_cat(categories, lang, source)
if source:getType() == "family" then
category = category:gsub("SOURCE", source:getCategoryName())
else
category = category:gsub("SOURCE", source:getCanonicalName())
end
table.insert(categories, lang:getCanonicalName() .. " " .. category)
local link = createLink(terminfo, template_name)
result = result .. " " .. export.format_etyl(lang, source, sort_key, categories, nocat) .. link
return result
end


-- Internal implementation of {{calque|...}} template
function export.calque(lang, terminfo, sort_key, nocap, notext, nocat)
local pre_text = ""
if not notext then
pre_text = pre_text .. "[[Appendix:Glossary#calque|" .. (nocap and "c" or "C") .. "alque]] of "
end

return specialized_borrowing(lang, terminfo, sort_key, nocat, pre_text, "calque", "terms calqued from SOURCE")
end


-- Internal implementation of {{partial calque|...}} template
function export.partial_calque(lang, terminfo, sort_key, nocap, notext, nocat)
local pre_text = ""
if not notext then
pre_text = pre_text .. "[[Appendix:Glossary#partial calque|" .. (nocap and "p" or "P") .. "artial calque]] of "
end

return specialized_borrowing(lang, terminfo, sort_key, nocat, pre_text, "partial_calque", "terms partially calqued from SOURCE")
end


-- Internal implementation of {{semantic loan|...}} template
function export.semantic_loan(lang, terminfo, sort_key, nocap, notext, nocat)
if nocap then
require("Module:debug").track("semantic_loan/nocap")
end

local pre_text = ""
if not notext then
pre_text = pre_text .. "[[Appendix:Glossary#semantic loan|" .. (nocap and "s" or "S") .. "emantic loan]] from "
end

return specialized_borrowing(lang, terminfo, sort_key, nocat, pre_text, "semantic_loan", "semantic loans from SOURCE")
end

-- Internal implementation of {{phono-semantic matching|...}} template
function export.phono_semantic_matching(lang, terminfo, sort_key, nocap, notext, nocat)
if nocap then
require("Module:debug").track("phono_semantic_matching/nocap")
end

local pre_text = ""
if not notext then
-- FIXME, create entry in [[Appendix:Glossary]]
pre_text = pre_text .. "[[w:Phono-semantic matching|" .. (nocap and "p" or "P") .. "hono-semantic matching]] of "
end
end


return specialized_borrowing(lang, terminfo, sort_key, nocat, pre_text, "phono_semantic_matching", "phono-semantic matchings from SOURCE")
return export.format_etyl(lang, source, sort_key, categories, nocat) ..
export.process_and_create_link(terminfo, "borrowed")
end
end



မူလိက်မပလေဝ်လဝ် နဒဒှ် ၁၄:၀၃၊ ၁ ဂျောန် ၂၀၂၃

Documentation for this module may be created at မဝ်ဂျူ:etymology/doc

local export = {}

-- For testing
local force_cat = false

local function term_error(terminfo)
	if terminfo.lang:hasType("family") then
		if terminfo.term and terminfo.term ~= "-" then
			require("Module:debug/track")("etymology/family/has-term")
		end
		
		terminfo.term = "-"
	end
	return terminfo
end


local function create_link(terminfo, template_name)
	local link = ""
	
	if terminfo.term == "-" then
		--[=[
		[[Special:WhatLinksHere/Template:tracking/cognate/no-term]]
		[[Special:WhatLinksHere/Template:tracking/derived/no-term]]
		[[Special:WhatLinksHere/Template:tracking/borrowed/no-term]]
		[[Special:WhatLinksHere/Template:tracking/calque/no-term]]
		]=]
		require("Module:debug/track")(template_name .. "/no-term")
	else
--		mw.log(terminfo.term)
		link = " " .. require("Module:links").full_link(terminfo, "term", true)
	end
	
	return link
end


function export.process_and_create_link(terminfo, template_name)
	terminfo = term_error(terminfo)
	return create_link(terminfo, template_name or "derived")
end
	

	if not categories then
		categories = {}
	end
	
	if source:getCode() == "und" then
		info = {
			display = "ဟွံသောင်ကၠး",
			cat_name = "ဘာသာတၞဟ်ဂမၠိုင်",
		}
	elseif source:getCode() == "mul" then
		info = {
			display = "[[w:Translingualism|translingual]]",
			cat_name = "Translingual",
		}
	elseif source:getCode() == "mul-tax" then
		info = {
			display = "[[:en:w:Translingualism|ယၟုအခေါန်ဖလှာ]]",
			cat_name = "taxonomic names",
		}
	else
		info.display = source:makeWikipediaLink()
		
		if source:getType() == "family" then
			info.cat_name = source:getCategoryName()
		else
			info.cat_name = source:getCanonicalName()
		end

	return display, cat_name
end


function export.insert_source_cat_get_display(categories, lang, source, raw, nocat)
	local display, cat_name = export.get_display_and_cat_name(source, raw)

	if lang and not nocat then
		-- Add the category, but only if there is a current language
		if not categories then
			categories = {}
		end
	
		if lang:getCode() == source:getCode() then
			--table.insert(categories, lang:getCanonicalName() .. " twice-borrowed terms")
		table.insert(categories,"ဝေါဟာ"..   lang:getCanonicalName() .. "လွဳၜါလောန်ဂမၠိုင်")
		else
			--table.insert(categories, lang:getCanonicalName() .. " terms derived from " .. cat_name)
			table.insert(categories, "ဝေါဟာ" .. lang:getCategoryName() .. "မဆက်ဆေန်ကၠုၚ်နူဝေါဟာ" .. cat_name)
		end
	end

	return display, categories
end


-- FIXME: rename to format_source()
function export.format_etyl(lang, source, sort_key, categories, nocat)
	-- [[Special:WhatLinksHere/Template:tracking/etymology/sortkey]]
	if sort_key then
		require("Module:debug/track")("etymology/sortkey")
	end

	local display
	display, categories = export.insert_source_cat_get_display(categories, lang, source, false, nocat)
	if lang and not nocat then
		-- Format categories, but only if there is a current language; {{cog}} currently gets no categories
		categories = require("Module:utilities").format_categories(categories, lang, sort_key, nil, force_cat)
	else
		categories = ""
	end
	
	return "<span class=\"etyl\">" .. display .. categories .. "</span>"
end


-- Internal implementation of {{cognate|...}} template
function export.format_cognate(terminfo, sort_key)
	return export.format_derived(nil, terminfo, sort_key, nil, "cognate")
end


-- Internal implementation of {{derived|...}} template
function export.format_derived(lang, terminfo, sort_key, nocat, template_name)
	local source = terminfo.lang
	return export.format_etyl(lang, source, sort_key, nil, nocat) .. export.process_and_create_link(terminfo, template_name)
end

-- Check that `lang` has `otherlang` (which may be an etymology-only language) as an ancestor. Throw an error if not.
local function check_ancestor(lang, otherlang)
	if not lang:hasAncestor(otherlang) and mw.title.getCurrentTitle().nsText ~= "แม่แบบ" then
		-- Generate the non-ancestor error message.
		local function showLanguage(lang)
			local retval = ("%s (%s)"):format(lang:makeCategoryLink(), lang:getCode())
			if lang:hasType("etymology-only") then
				retval = retval .. (" (an etymology-only language whose regular parent is %s)"):format(
					showLanguage(lang:getParent()))
			end
			return retval
		end
		local postscript
		local ancestors = lang:getAncestors()
		local moduleLink = "[[Module:"
			.. require("Module:languages").getDataModuleName(lang:getCode())
			.. "]]"
		if not ancestors[1] then
			postscript = showLanguage(lang) .. " has no ancestors."
		else
			local ancestorList = table.concat(
				require("Module:fun").map(
					showLanguage,
					ancestors),
				" and ")
			postscript = ("The ancestor%s of %s %s %s."):format(
				ancestors[2] and "s" or "", lang:getCanonicalName(),
				ancestors[2] and "are" or "is", ancestorList)
		end
		error(("%s is not set as an ancestor of %s in %s. %s")
			:format(showLanguage(otherlang), showLanguage(lang), moduleLink, postscript))
	end
end


-- Internal implementation of {{inherited|...}} template
function export.format_inherited(lang, terminfo, sort_key, nocat)
	local source = terminfo.lang
	
	local categories = {}
	if not nocat then
		--table.insert(categories, lang:getCanonicalName() .. " terms inherited from " .. source:getCanonicalName())
	table.insert(categories,"ဝေါဟာ"..  lang:getCanonicalName() .. "ဂွံလဝ်အာဲကၟာဲနူဝေါဟာ" .. source:getCanonicalName() ..  "ဂမၠိုင်")
	end

	local link = export.process_and_create_link(terminfo, "inherited")
	
	check_ancestor(lang, source)

	return export.format_etyl(lang, source, sort_key, categories, nocat) .. link
end


function export.insert_borrowed_cat(categories, lang, source)
	local category
	if lang:getCode() == source:getCode() then
		--category = " twice-borrowed terms"
		table.insert(categories,"ဝေါဟာ"..   lang:getCanonicalName() .. "လွဳၜါလောန်ဂမၠိုင်")
	else
		--category = " terms borrowed from " .. source:getDisplayForm()
		table.insert(categories,"ဝေါဟာ" .. lang:getCanonicalName() .. "လွဳလဝ် နူဝေါဟာ" .. source:getCategoryName() ..  "ဂမၠိုင်")
	end
	--table.insert(categories, lang:getCanonicalName() .. category)
	table.insert(categories, category)
end


-- Internal implementation of {{borrowed|...}} template.
function export.format_borrowed(lang, terminfo, sort_key, nocat)
	local source = terminfo.lang
	
	local categories = {}
	if not nocat then
		export.insert_borrowed_cat(categories, lang, source)
	end

	return export.format_etyl(lang, source, sort_key, categories, nocat) ..
		export.process_and_create_link(terminfo, "borrowed")
end

return export