မာတိကာသို့ ခုန်သွားရန်

မဝ်ဂျူ:cau-entryname

နူ ဝိက်ရှေန်နရဳ

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

local export = {}
local u = mw.ustring.char

local remove_diacritics = u(0x0300) .. u(0x0301) .. u(0x0304) -- grave, acute, macron

local Cyrl = {
	["I"] = "ӏ", ["l"] = "ӏ", ["І"] = "ӏ", ["Ӏ"] = "ӏ", ["ᴴ"] = "ᵸ"
}

function export.makeEntryName(text, lang, sc)
	if sc == "Cyrl" then -- if script is Cyrillic, correct "false" palochkas and dialectal nasal ᵸ written as Latin ᴴ; not desirable if using another script
		text = mw.ustring.gsub(text, ".", Cyrl)
	end
	
	return mw.ustring.toNFC(mw.ustring.gsub(mw.ustring.toNFD(text), "[" .. remove_diacritics .. "]", "")) -- decompose, remove appropriate diacritics, then recompose again
end

return export