ข้ามไปเนื้อหา

มอดูล:nod-alt

จาก วิกิพจนานุกรม พจนานุกรมเสรี

local export = {}
local links = require("Module:links")
local gsub = mw.ustring.gsub

local lang = require("Module:languages").getByCode("nod")
local script1 = require("Module:scripts").getByCode("Lana")
local script2 = require("Module:scripts").getByCode("Thai")
local PAGENAME = mw.title.getCurrentTitle().text

function export.show(frame)

	local args = frame:getParent().args

	local common = args["c"] or args["common"]
	local commonForms = (common and mw.text.split(common, ",", true) or {})

	local nonstandard = args["ns"] or args["nonstandard"]
	local nonstandardForms = (nonstandard and mw.text.split(nonstandard, ",", true) or {})

	local transliteration = args["tl"] or args["l"] or args["transliteration"]
	local transliteratedForms = (transliteration and mw.text.split(transliteration, ",", true) or {})

	local transcription = args["ts"] or args["s"] or args["transcription"]
	local transcribedForms = (transcription and mw.text.split(transcription, ",", true) or {})

	local transliterationAndTranscription = args["tlts"] or args["tstl"] or args["ls"] or args["sl"] or args["~"]
	local transliteratedAndTranscribedForms = (transliterationAndTranscription and mw.text.split(transliterationAndTranscription, ",", true) or {})

	local followingThai = args["fth"] or args["ft"] or args["f"] or args["followingThai"]
	local followedThaiForms = (followingThai and mw.text.split(followingThai, ",", true) or {})

	local altForms = { ["common"] = commonForms, ["nonstandard"] = nonstandardForms, ["transliteration"] = transliteratedForms, ["transcription"] = transcribedForms, ["transliterationAndTranscription"] = transliteratedAndTranscribedForms, ["followingThai"] = followedThaiForms}

	local output = "<ul>"
	for _,term in ipairs(altForms.common) do
		output = output .. "<li>" .. links.full_link({lang = lang, term = term, sc = script1}) .. "</li>"
	end

	for _,term in ipairs(altForms.nonstandard) do
		output = output .. "<li>(<i>ไม่มาตรฐาน</i>) " .. links.full_link({lang = lang, term = term, sc = script1}) .. "</li>"
	end

	for _,term in ipairs(altForms.transliteration) do
		output = output .. "<li>(<i>ถอดอักษร</i>) " .. links.full_link({lang = lang, term = term, sc = script2}) .. "</li>"
	end

	for _,term in ipairs(altForms.transcription) do
		output = output .. "<li>(<i>ถอดเสียง</i>) " .. links.full_link({lang = lang, term = term, sc = script2}) .. "</li>"
	end

	for _,term in ipairs(altForms.transliterationAndTranscription) do
		output = output .. "<li>(<i>ถอดอักษรและถอดเสียง</i>) " .. links.full_link({lang = lang, term = term, sc = script2}) .. "</li>"
	end

	for _,term in ipairs(altForms.followingThai) do
		output = output .. "<li>(<i>ตามภาษาไทย</i>) " .. links.full_link({lang = lang, term = term, sc = script2}) .. "</li>"
	end

	output = output .. "</ul>"

	return output

end

return export