มอดูล:Thaa-translit

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

This module will transliterate text in the อักษรทานะ. It is used to transliterate มัลดีฟส์ (dv). The module should preferably not be called directly from templates or other modules. To use it from a template, use {{xlit}}. Within a module, use Module:languages#Language:transliterate.

For testcases, see Module:Thaa-translit/testcases.

Functions

tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by the code sc, and language specified by the code lang.
When the transliteration fails, returns nil.

local export = {}
local u = mw.ustring.char
 
local consonants = {
	["ހ"] = "ห", ["ށ"] = "ษ", ["ނ"] = "น", ["ރ"] = "ร", ["ބ"] = "พ",
	["ޅ"] = "ฬ", ["ކ"] = "ก", ["އ"] = "อ", ["ވ"] = "ว", ["މ"] = "ม",
	["ފ"] = "ฟ", ["ދ"] = "ท", ["ތ"] = "ต", ["ލ"] = "ล", ["ގ"] = "ค",
	["ޏ"] = "ญ", ["ސ"] = "ส", ["ޑ"] = "ฑ", ["ޒ"] = "ซ", ["ޓ"] = "ฏ",
	["ޔ"] = "ย", ["ޕ"] = "ป", ["ޖ"] = "ช", ["ޗ"] = "จ", ["ޱ"] = "ณ",
	["ޘ"] = "ṯ", ["ޙ"] = "ḥ", ["ޚ"] = "x", ["ޛ"] = "ź", ["ޜ"] = "ž",
	["ޝ"] = "ศ", ["ޞ"] = "ş", ["ޟ"] = "ḋ", ["ޠ"] = "ţ", ["ޡ"] = "ẓ",
	["ޢ"] = "ʿ", ["ޣ"] = "ġ", ["ޤ"] = "q", ["ޥ"] = "w",

}

local diacritics = {
	[u(0x07A6)] = "ะ", [u(0x07A7)] = "า", [u(0x07A8)] = "ิ", [u(0x07A9)] = "ี", [u(0x07AA)] = "ุ",
	[u(0x07AB)] = "ู", [u(0x07AC)] = "↶เะ", [u(0x07AD)] = "↶เ", [u(0x07AE)] = "↶โะ", [u(0x07AF)] = "↶โ", [u(0x07B0)] = "์",
	-- no diacritic
	[""] = "ะ"
}

function export.tr(text, lang, sc)
	text = mw.ustring.gsub(
		text,
		"([ހ-ޥޱ])(["..u(0x07A6).."-"..u(0x07B0).."]?)",
		function(c, d)
			return consonants[c] .. diacritics[d]
		end)

	text = mw.ustring.gsub(text, "([ก-ฮ])↶([เโ])", "%2%1")
	text = mw.ustring.gsub(text, "([เโ])([ก-ฮ])ะ([ก-ฮ]์)", "%1%2็%3")
	text = mw.ustring.gsub(text, "([ก-ฮ])ะ([ก-ฮ]์)", "%1ั%2")

	return text
end
 
return export