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

Module:Phnx-translit


这个模组会将腓尼基字母文字转写为拉丁字母。

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

关于测试用例,请参阅Module:Phnx-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

-- Beware! Phnx is rtl
local tt = {
	['𐤀'] = 'ʾ', ['𐤁'] = 'b', ['𐤂'] = 'g', ['𐤃'] = 'd', ['𐤄'] = 'h',
	['𐤅'] = 'w', ['𐤆'] = 'z', ['𐤇'] = 'ḥ', ['𐤈'] = 'ṭ', ['𐤉'] = 'y',
	['𐤊'] = 'k', ['𐤋'] = 'l', ['𐤌'] = 'm', ['𐤍'] = 'n', ['𐤎'] = 's',
	['𐤏'] = 'ʿ', ['𐤐'] = 'p', ['𐤑'] = 'ṣ', ['𐤒'] = 'q', ['𐤓'] = 'r',
	['𐤔'] = 'š', ['𐤕'] = 't',
	['𐤖'] = '[1]', ['𐤗'] = '[10]', ['𐤘'] = '[20]', ['𐤙'] = '[100]',
	['𐤚'] = '[2]', ['𐤛'] = '[3]', ['𐤟'] = ' ',
}

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

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

	return (text:gsub('[%z\1-\127\194-\244][\128-\191]*', tt)) -- UTF-8 character pattern
end

return export