มอดูล:Geor-translit

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

This module will transliterate text in the อักษรจอร์เจีย. It is used to transliterate อูดี (udi), อับคาเซีย (ab), บัตส์ (bbl), ออสซีเซีย (os), มิงเกรเลีย (xmf), จอร์เจีย (ka), and จอร์เจียเก่า (oge). 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:Geor-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 gsub = mw.ustring.gsub
local u = mw.ustring.char
local letter_with_mark = '(.ฺ?['..u(0x0300)..'-'..u(0x036F)..']*)'
 
local tt = {
	-- consonants & back vowels
	['ა'] = 'า', ['ბ'] = 'บ', ['გ'] = 'กฺ', ['დ'] = 'ด', ['ვ'] = 'วฺ', ['ზ'] = 'ซฺ', 
	['თ'] = 'ท', ['ი'] = 'ี', ['კ'] = 'ก͓', ['ლ'] = 'ล', ['მ'] = 'ม', ['ნ'] = 'น', ['ჼ'] = 'น์', ['ჲ'] = 'ย', ['ო'] = 'อ̂',
	['პ'] = 'ป͓', ['ჟ'] = 'ฌฺ', ['რ'] = 'ร', ['ს'] = 'ซ', ['ტ'] = 'ต͓', ['ჳ'] = 'ว', ['უ'] = 'ู', ['ფ'] = 'พ',
	['ქ'] = 'ค', ['ღ'] = 'ฆ', ['ყ'] = 'ฃ͓', ['შ'] = 'ฌ', ['ჩ'] = 'ช', ['ც'] = 'ท͜ซ',
	['ძ'] = 'ด͜ซฺ', ['წ'] = 'ต͜ซ͓', ['ჭ'] = 'จ͓', ['ხ'] = 'ฅ',
	['ჴ'] = 'ฃ', ['ჯ'] = 'จฺ', ['ჰ'] = 'ฮ', ['ჶ'] = 'ฟ', ['ჸ'] = 'อ', ['ჺ'] = 'อฺ',
	-- some punctuations
	['„'] = '“', ['“'] = '”', ['჻'] = '๚',
}

local adjust1 = {
	-- front vowels
	['ე'] = 'แ%1', ['ჱ'] = 'เ%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 = mw.ustring.lower(text) -- to support Georgian Extended

	-- เติม อ ถ้าพยางค์แรกเป็นสระ หรือสระติดกัน
	text = gsub(text, '^([აიოუეჱჵჷჽ])', 'ჸ%1')
	text = gsub(text, '([%s%p%d])([აიოუეჱჵჷჽ])', '%1ჸ%2')
	text = gsub(text, '([აიოუეჱჵჷჽ])([აიოუეჱჵჷჽ])', '%1ჸ%2')
	text = gsub(text, '([აიოუეჱჵჷჽ])([აიოუეჱჵჷჽ])', '%1ჸ%2') --twice

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

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

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

	return text

end
 
return export