Bước tới nội dung

Mô đun:Deva-as-Beng-translit

Từ điển mở Wiktionary
local export = {}

local char = {
	["र"] = "ৰ", ["व"] = "ৱ"
}

-- Override returns text even if some characters cannot be transliterated.
-- If noKhandaTa is set, then "ৎ" will not be contextually substituted for "ত্", which is suitable (e.g.) for Sanskrit transliteration.
function export.tr(text, lang, sc, override, noKhandaTa)
	local UTF8_char = "[%z\1-\127\194-\244][\128-\191]*"
	local asBeng = require("Module:scripts").getByCode("as-Beng")
	text = mw.ustring.toNFD(text)
	
	text = string.gsub(text, UTF8_char, char)
	text = require("Module:Deva-Beng-translit").tr(text, lang, sc, true, noKhandaTa)
	
	-- Khanda Ta is not used in Sanskrit.
	if not noKhandaTa and lang ~= "sa" then
		text = mw.ustring.gsub(text, "ৎ(ৰ)", "ত্%1")
	end
	
	local reducedText = mw.ustring.gsub(mw.ustring.gsub(text, "<.->", ""), "[%s%p\n]+", "")
	if (mw.ustring.len(reducedText) == asBeng:countCharacters(reducedText) and not mw.ustring.find(text, "়়")) or override then
		return text
	else
		return nil
	end
end

return export