logo

Module:Tale-translit是什么意思_Module:Tale-translit读音|解释_Module:Tale-translit同义词|反义词

Module:Tale-translit


这个模组会将德宏傣文文字转写为拉丁字母。

最好不要直接从模板或其他模组调用此模组。要从模板中使用它,请以{{xlit}}做为替代;若要在模组中使用,则以Module:languages#Language:transliterate替代。

关于测试用例,请参阅Module:Tale-translit/testcases。

函数

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
-- pattern ([ᥐ-ᥢ])([ᥣ-ᥬ]?)([ᥐᥒᥖᥙᥛᥝᥢᥭ{m}]?)([ᥰ-ᥴ{dia-tones}]?)

local tt = {
	-- consonants
	['ᥐ'] = 'k', ['ᥑ'] = 'x', ['ᥒ'] = 'ng', ['ᥓ'] = 'ts', ['ᥔ'] = 's', ['ᥕ'] = 'y',
	['ᥖ'] = 't', ['ᥗ'] = 'th', ['ᥘ'] = 'l', ['ᥙ'] = 'p', ['ᥚ'] = 'ph', ['ᥛ'] = 'm',
	['ᥜ'] = 'f', ['ᥝ'] = 'v', ['ᥞ'] = 'h', ['ᥟ'] = '’', ['ᥠ'] = 'kh', ['ᥡ'] = 'tsh', ['ᥢ'] = 'n',
	-- vowels
	['ᥣ'] = 'aa', ['ᥤ'] = 'i', ['ᥥ'] = 'e', ['ᥦ'] = 'ae', ['ᥧ'] = 'u',
	['ᥨ'] = 'o', ['ᥩ'] = 'oa', ['ᥪ'] = 'ue', ['ᥫ'] = 'oe', ['ᥬ'] = 'aue',
	['ᥭ'] = 'y', [u(0x030A)] = 'm', [u(0x02DA)] = 'm',
	-- tones (different order from Unicode) http://www.seasite.niu.edu/tai/TaiDehong/index.htm
	['ᥰ'] = '<sup>2</sup>', [u(0x0308)] = '<sup>2</sup>', [u(0x00A8)] = '<sup>2</sup>',
	['ᥱ'] = '<sup>3</sup>', [u(0x030C)] = '<sup>3</sup>', [u(0x02C7)] = '<sup>3</sup>',
	['ᥲ'] = '<sup>4</sup>', [u(0x0300)] = '<sup>4</sup>', [u(0x0060)] = '<sup>4</sup>', [u(0x02CB)] = '<sup>4</sup>',
	['ᥳ'] = '<sup>5</sup>', [u(0x0307)] = '<sup>5</sup>', [u(0x02D9)] = '<sup>5</sup>',
	['ᥴ'] = '<sup>1</sup>', [u(0x0301)] = '<sup>1</sup>', [u(0x00B4)] = '<sup>1</sup>', [u(0x02CA)] = '<sup>1</sup>',
	-- tone 6 unmarked
}

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, '([ᥐ-ᥢ])([ᥐᥒᥖᥙᥛᥝᥢᥭ'..u(0x030A)..u(0x02DA)..'])', '%1a%2')

	text = gsub(text, '.', tt)
	
	text = gsub(text, '([aeiou])v', '%1w')

	return text

end

return export