มอดูล:Sund-translit

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

มอดูลนี้ใช้ถอดอักษรข้อความในอักษรซุนดา.

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 มอดูล:Sund-translit/testcases.

ฟังก์ชัน[แก้]

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

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

local tt = {
	-- initials
	['ᮊ'] = 'ก', ['ᮋ'] = 'ก̱', ['ᮌ'] = 'ค', ['ᮍ'] = 'ง',
	['ᮎ'] = 'จ', ['ᮏ'] = 'ช', ['ᮐ'] = 'ซ', ['ᮑ'] = 'ญ',
	['ᮒ'] = 'ต', ['ᮓ'] = 'ท', ['ᮔ'] = 'น',
	['ᮕ'] = 'ป', ['ᮖ'] = 'ฟ', ['ᮗ'] = 'ฝ', ['ᮘ'] = 'พ', ['ᮽ'] = 'ภ', ['ᮙ'] = 'ม',
	['ᮚ'] = 'ย', ['ᮛ'] = 'ร', ['ᮜ'] = 'ล', ['ᮝ'] = 'ว',
	['ᮞ'] = 'ส', ['ᮟ'] = 'ฅ', ['ᮠ'] = 'ห', ['ᮮ'] = 'ฆ', ['ᮯ'] = 'ศ', ['ᮺ'] = '-',
	-- medials
	['ᮡ'] = 'ฺย', ['ᮢ'] = 'ฺร', ['ᮣ'] = 'ฺล', ['ᮬ'] = 'ฺม', ['ᮭ'] = 'ฺว',
	-- independent vowels
	['ᮃ'] = 'อ', ['ᮄ'] = 'อิ', ['ᮅ'] = 'อุ',
	['ᮆ'] = 'อ↶แ', ['ᮇ'] = 'ออ̂', ['ᮈ'] = 'อ↶เ', ['ᮉ'] = 'อ↶เอ̂',
	['ᮻ'] = 'ฤ', ['ᮼ'] = 'ฦ',
	-- dependent vowels and diacritics
	['ᮤ'] = 'ิ', ['ᮥ'] = 'ุ',
	['ᮦ'] = '↶แ', ['ᮧ'] = 'อ̂', ['ᮨ'] = '↶เ', ['ᮩ'] = '↶เอ̂',
	['᮪'] = 'ฺ', ['᮫'] = 'ฺ',
	['ᮀ'] = 'ํ', ['ᮁ'] = 'รฺ', ['ᮂ'] = 'ห์',
	-- finals
	['ᮾ'] = 'กฺ', ['ᮿ'] = 'มฺ',
	-- numerals
	['᮰'] = '0', ['᮱'] = '1', ['᮲'] = '2', ['᮳'] = '3', ['᮴'] = '4',
	['᮵'] = '5', ['᮶'] = '6', ['᮷'] = '7', ['᮸'] = '8', ['᮹'] = '9',
	-- zero-width space (display it if it hides in a word)
	[u(0x200B)] = '‼',
}

function export.tr(text, lang, sc, debug_mode)

	if type(text) == 'table' then -- called directly from a template
		text = text.args[1]
	end

	text = gsub(text, '.', tt)

	text = gsub(text, '([ก-ฮ]̱?)↶([เแ])', '%2%1')

	-- ย้ายสัญลักษณ์ขึ้นบน เมื่อมีสระล่าง (ยกเว้นตัวที่ไม่มี)
	text = gsub(text, u(0x0331)..'([ุ-ฺ])', u(0x0304)..'%1') -- macron below > macron above

	return text

end

return export