Module:Cans-translit/sandbox

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local data = {
	{ --short-vowel
		"ᐁᐃᐅᐊᐯᐱᐳᐸᑌᑎᑐᑕᑫᑭᑯᑲᒉᒋᒍᒐᒣᒥᒧᒪᓀᓂᓄᓇᓭᓯᓱᓴᔦᔨᔪᔭᖊᖋᖌᖍᕃᕆᕈᕍᕂᕄᕊᕋᔐᔑᔓᔕᕓᕕᕗᕙᕞᕠᕤᕦᘚᘛᘕᘔᓓᓕᓗᓚᙯᕿᖁᖃᙰᖏᖑᖓ ᙱᙳᙵᕴᕵᕷᕹ",
		"1ptkcmnsyrrršfðzlq23h",
		{"","ng","nng"},
		"eioa",
		function(a,b)
			return a..b
		end
	},
	{ --w
		"ᐌᐍᐎᐏᐒᐓᐗᐘᐺᐻᐼᐽᑀᑁᑄᑅᑗᑘᑙᑚᑝᑞᑡᑢᑴᑵᑶᑷᑺᑻᑾᑿᒒᒓᒔᒕᒘᒙᒜᒝᒬᒭᒮᒯᒲᒳᒶᒷ"
			.. "ᓉᓊ  ᓋᓌ  ᓶᓷᓸᓹᓼᓽᔀᔁᔯᔰᔱᔲᔵᔶᔹᔺᔗᔘᔙᔚᔝᔞᔡᔢᓜᓝᓞᓟᓢᓣᓦᓧ",
		"1ptkcmnsyrz",
		{""},
		"eeiiooaa",
		function(a,b)
			return a..'w'..b
		end
	},
	{ --long-vowel
		"ᐄᐆᐋᐲᐴᐹᑏᑑᑖᑮᑰᑳᒌᒎᒑᒦᒨᒫᓃᓅᓈᓰᓲᓵᔩᔫᔮᕇᕉᕌᔒᔔᔖᕖᕘᕚᕢᕥᕧᓖᓘᓛᐐᐔᐙᖀᖂᖄᕶᕸᕺ",
		"1ptkcmnsyršfðlwqh",
		{""},
		"īōā",
		function(a,b)
			return a..b
		end
	},
	{ --w-long
		"ᐐᐑᐔᐕᐖᐙᐚᐛᐾᐿᑂᑃ ᑆᑇᑈᑛᑜᑟᑠ ᑣᑤᑥᑸᑹᑼᑽ ᒀᒁᒂᒖᒗᒚᒛ ᒞᒟᒠᒰᒱᒴᒵ ᒸᒹᒺ     ᓍᓎᓏ"
			.. "ᓠᓡᓤᓥ ᓨᓩ ᓺᓻᓾᓿ ᔂᔃᔄᔛᔜᔟᔠ ᔣᔤ ᔳᔴᔷᔸ ᔻᔼᔽ     ᕎᕏ      ᕛᕜ      ᕨᕩ ",
		"1ptkcmnlsšyrfð",
		{""},
		"īīōōōāāā",
		function(a,b)
			return a..'w'..b
		end
	},
	{ --individual
		"ᑊᐟᐠᐨᒼᐣᐢᐧᐤᐦᕁᕽᓫᕑᑉᑦᒡᒃᒻᓐᔅᔥᔾᓪᕐᕪ‡ᒄᔉᖅᖕᖖᕝᖦᕀᕻᕼ",
		"ptkcmnsywh11lrptckmnsšylrðð23q45vlyhh",
		{"hk","kw","sk","ng","nng"},
	},
}

--[[
function export.tr(text, lang, sc)
	for i, item in pairs(data) do
		if item[4] then
			local length = mw.ustring.len(item[4])
			for c = 1, mw.ustring.len(item[1]) do
				local s = mw.ustring.sub(item[1], c, c)
				local index = math.ceil(c / length)
				local a = mw.ustring.sub(item[2], index, index)
				if tonumber(a) then
					a = item[3][tonumber(a)]
				end
				index = (c - 1) % length + 1
				local b = mw.ustring.sub(item[4], index, index)
				if s ~= " " then
					text = mw.ustring.gsub(text, s, item[5](a,b))
				end
			end
		else
			for c = 1, mw.ustring.len(item[1]) do
				local s = mw.ustring.sub(item[1], c, c)
				local a = mw.ustring.sub(item[2], c, c)
				if tonumber(a) then
					a = item[3][tonumber(a)]
				end
				text = mw.ustring.gsub(text, s, a)
			end
		end
	end
	return text
end
]]

function export.show(frame)
	local dump = require('Module:debug').highlight_dump
	local restructured = {}
	
	for i, item in pairs(data) do
		if not item[4] then
			local subtable = {}
			for c = 1, mw.ustring.len(item[1]) do
				local s = mw.ustring.sub(item[1], c, c)
				local a = mw.ustring.sub(item[2], c, c)
				if tonumber(a) then
					a = item[3][tonumber(a)]
				end
				table.insert(subtable, { s, a })
			end
			restructured[i] = subtable
		end
	end
	return dump(restructured)
end

return export