มอดูล:Geor-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 มอดูล:Geor-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 letter_with_mark = '(.['..u(0x0300)..'-'..u(0x036F)..']*)'
 
local tt = {
	-- consonants & back vowels
	['ა'] = 'า', ['ბ'] = 'บ', ['გ'] = 'ก̱', ['დ'] = 'ด', ['ვ'] = 'ฝ', ['ზ'] = 'ซ̱', 
	['თ'] = 'ท', ['ი'] = 'ี', ['კ'] = 'ก͓', ['ლ'] = 'ล', ['მ'] = 'ม', ['ნ'] = 'น', ['ჼ'] = '<sup>น</sup>', ['ჲ'] = 'ย', ['ო'] = 'อ̂',
	['პ'] = 'ป͓', ['ჟ'] = 'ฌ̱', ['რ'] = 'ร', ['ს'] = 'ซ', ['ტ'] = 'ต͓', ['ჳ'] = 'ว', ['უ'] = 'ู', ['ფ'] = 'พ',
	['ქ'] = 'ค', ['ღ'] = 'ฆ̱', ['ყ'] = 'ก͇', ['შ'] = 'ฌ', ['ჩ'] = 'ช', ['ც'] = 'ท͡ซ',
	['ძ'] = 'ด͡ซ', ['წ'] = 'ต͡ซ͓', ['ჭ'] = 'จ͓', ['ხ'] = 'ฆ',
	['ჴ'] = 'ก͇͓', ['ჯ'] = 'จ̱', ['ჰ'] = 'ฮ', ['ჶ'] = 'ฟ', ['ჸ'] = 'อ',
	-- some punctuations
	['„'] = '“', ['“'] = '”', ['჻'] = '๚',
}

local adjust1 = {
	-- front vowels
	['ე'] = 'แ%1', ['ჱ'] = 'เ%1', ['ჵ'] = 'โ%1', ['ჷ'] = 'เ%1อ'
}

function export.tr(text, lang, sc)

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

	-- ถ้าพยางค์แรกไม่มีพยัญชนะ เติม อ ลงไป
	text = gsub(text, '^([აიოუეჱჵჷ])', 'ჸ%1')
	text = gsub(text, '([%s%p%d])([აიოუეჱჵჷ])', '%1ჸ%2')

	-- สระซ้ำสองตัว ตัดออกตัวนึง
	text = gsub(text, '([აიოუეჱჵჷ])%1', '%1')

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

	for k, v in pairs(adjust1) do
		text = gsub(text, letter_with_mark..k, v)
	end

	-- ปรับแต่งสระ
	text = gsub(text, '([เแโ])'..letter_with_mark..'า', '%1%2อา')
	text = gsub(text, '([เแโ])'..letter_with_mark..'ี', '%1%2ย')
	text = gsub(text, '([เแโ])'..letter_with_mark..'ู', '%1%2ว')
	text = gsub(text, '([เแโ])'..letter_with_mark..'อ̂', '%1%2ออ̂')

	text = gsub(text, 'าี', 'าย')
	text = gsub(text, 'าู', 'าว')
	text = gsub(text, 'าอ̂', 'าออ̂')
	text = gsub(text, 'เา', 'าเอ')
	text = gsub(text, 'แา', 'าแอ')
	text = gsub(text, 'โา', 'าโอ')

	text = gsub(text, letter_with_mark..'ีา', 'เ%1ีย')
	text = gsub(text, 'ี' .. 'ู', 'ีว')
	text = gsub(text, 'ีอ̂', 'ีออ̂')
	text = gsub(text, 'เี', 'ีเอ')
	text = gsub(text, 'แี', 'ีแอ')
	text = gsub(text, 'โี', 'ีโอ')

	text = gsub(text, 'ูา', 'ัว')
	text = gsub(text, 'ู' .. 'ี', 'ูย')

	text = gsub(text, 'อ̂ี', 'อ̂ย')
	text = gsub(text, 'อู̂', 'อ̂ว')
	text = gsub(text, 'เอ̂', 'อ̂เอ')
	text = gsub(text, 'แอ̂', 'อ̂แอ')
	text = gsub(text, 'โอ̂', 'อ̂โอ')

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

	-- ย้ายสัญลักษณ์ลงล่าง เมื่อมีสระบน (ยกเว้นตัวที่ไม่มี)
	text = gsub(text, u(0x0361)..'(.'..u(0x0353)..'?ี)', u(0x035C)..'%1') -- tie above > tie below

	return text

end
 
return export