This module will transliterate text in the อักษรลาว. It is used to transliterate สันสกฤต (sa), บาลี (pi), ลาว (lo), and ขมุ (kjg).

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:Laoo-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.

ข้อผิดพลาดสคริปต์: ไม่มีมอดูล "module categorization"


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

local tt = {
	-- consonants
	["ກ"] = "ก", ["ຂ"] = "ข", ["ຄ"] = "ค", ["ງ"] = "ง", ["ຈ"] = "จ",
	["ຊ"] = "ซ", ["ຍ"] = "ย̃", ["ດ"] = "ด", ["ຕ"] = "ต", ["ຖ"] = "ถ",
	["ທ"] = "ท", ["ນ"] = "น", ["ບ"] = "บ", ["ປ"] = "ป", ["ຜ"] = "ผ",
	["ຝ"] = "ฝ", ["ພ"] = "พ", ["ຟ"] = "ฟ", ["ມ"] = "ม", ["ຢ"] = "ย",
	["ຣ"] = "ร", ["ລ"] = "ล", ["ວ"] = "ว", ["ສ"] = "ส", ["ຫ"] = "ห",
	["ອ"] = "อ", ["ຮ"] = "ฮ", ["ຼ"] = "ล", ["ຽ"] = "ย͢",
	["ໜ"] = "หน", ["ໝ"] = "หม", ["ໞ"] = "ก̷", ["ໟ"] = "ย̷̃",
	-- Pali and Sanskrit
	["ຆ"] = "ฆ", ["ຉ"] = "ฉ", ["ຌ"] = "ฌ", ["ຎ"] = "ญ",
	["ຏ"] = "ฏ", ["ຐ"] = "ฐ", ["ຑ"] = "ฑ", ["ຒ"] = "ฒ", ["ຓ"] = "ณ",
	["ຘ"] = "ธ", ["ຠ"] = "ภ", ["ຨ"] = "ศ", ["ຩ"] = "ษ", ["ຬ"] = "ฬ", ["຺"] = "ฺ",
	-- punctuations
	["ຯ"] = "ฯ", ["ໆ"] = "ๆ",
	-- vowels
	["ະ"] = "ะ", ["ັ"] = "ั", ["າ"] = "า", ["ຳ"] = "ำ",
	["ິ"] = "ิ", ["ີ"] = "ี", ["ຶ"] = "ึ", ["ື"] = "ื",
	["ຸ"] = "ุ", ["ູ"] = "ู", ["ົ"] = "็",
	["ເ"] = "เ", ["ແ"] = "แ", ["ໂ"] = "โ", ["ໃ"] = "ใ", ["ໄ"] = "ไ",
	-- tones and diacritics
	["່"] = "่", ["້"] = "้", ["໊"] = "๊", ["໋"] = "๋", ["໌"] = "์", ["ໍ"] = "ํ",
	-- numerals
	["໐"] = "๐", ["໑"] = "๑", ["໒"] = "๒", ["໓"] = "๓", ["໔"] = "๔",
	["໕"] = "๕", ["໖"] = "๖", ["໗"] = "๗", ["໘"] = "๘", ["໙"] = "๙",
	-- zero-width space (display it if it hides in a word)
	[u(0x200B)] = "‼", [u(0x200C)] = "‼", [u(0x200D)] = "‼",
}

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)

	if lang == "pi" or lang == "sa" then
		text = gsub(text, "ซ", "ช")
		text = gsub(text, u(0x0303), "")
	end

	-- ย้ายสัญลักษณ์ลงล่าง เมื่อมีสระบนและวรรณยุกต์
	text = gsub(text, u(0x0303).."([ัำิ-ื็-๎])", u(0x0330).."%1") -- tilde above > tilde below

	return text

end

return export