सामग्रीमा जानुहोस्

मोड्युल:Grek-common

Wiktionaryबाट

Documentation for this module may be created at मोड्युल:Grek-common/doc

local export = {}

local toNFC = mw.ustring.toNFC
local toNFD = mw.ustring.toNFD
local u = require("Module:string/char")
local ugsub = mw.ustring.gsub

local PRIME = u(0x02B9)
local CARON = u(0x030C)
local DIAERBELOW = u(0x0324)
local BREVEBELOW = u(0x032E)
local KERAIA = u(0x0374)
local CORONIS = u(0x1FBD)
local PSILI = u(0x1FBF)
local RSQUO = u(0x2019)

local displaytext_substitutes = {
	["'"] = RSQUO,
	[PRIME] = RSQUO,
	[KERAIA] = RSQUO,
	[CORONIS] = RSQUO,
	[PSILI] = RSQUO,
	["Þ"] = "Ϸ",
	["þ"] = "ϸ",
}

function export.makeDisplayText(text, lang, sc)
	return toNFC(ugsub(toNFD(text), "['" .. PRIME .. KERAIA .. CORONIS .. PSILI .. "Þþ]", displaytext_substitutes))
end

local entryname_substitutes = {}
for k, v in pairs(displaytext_substitutes) do
	entryname_substitutes[k == "'" and RSQUO or k] = v == RSQUO and "'" or v
end

function export.makeEntryName(text, lang, sc)
	text = ugsub(toNFD(text), "[" .. PRIME .. KERAIA .. CORONIS .. PSILI .. RSQUO .. "Þþ]", entryname_substitutes)
	if sc == "Grek" then
		text = ugsub(toNFD(text), "[" .. CARON .. DIAERBELOW .. BREVEBELOW .. "]+", "")
	end
	return toNFC(text)
end

return export